REORG: http: move some very http1-specific parts to h1.{c,h}
Certain types and enums are very specific to the HTTP/1 parser, and we'll
need to share them with the HTTP/2 to HTTP/1 translation code. Let's move
them to h1.c/h1.h. Those with very few occurrences or only used locally
were renamed to explicitly mention the relevant HTTP version :
enum ht_state -> h1_state.
http_msg_state_str -> h1_msg_state_str
HTTP_FLG_* -> H1_FLG_*
http_char_classes -> h1_char_classes
Others like HTTP_IS_*, HTTP_MSG_* are left to be done later.
diff --git a/include/types/proto_http.h b/include/types/proto_http.h
index 1d378ac..3f99df7 100644
--- a/include/types/proto_http.h
+++ b/include/types/proto_http.h
@@ -27,6 +27,7 @@
#include <common/mini-clist.h>
#include <common/regex.h>
+#include <types/h1.h>
#include <types/hdr_idx.h>
#include <types/filters.h>
#include <types/sample.h>
@@ -124,65 +125,6 @@
*
*/
-/* Possible states while parsing HTTP messages (request|response) */
-enum ht_state {
- HTTP_MSG_RQBEFORE = 0, // request: leading LF, before start line
- HTTP_MSG_RQBEFORE_CR = 1, // request: leading CRLF, before start line
- /* these ones define a request start line */
- HTTP_MSG_RQMETH = 2, // parsing the Method
- HTTP_MSG_RQMETH_SP = 3, // space(s) after the Method
- HTTP_MSG_RQURI = 4, // parsing the Request URI
- HTTP_MSG_RQURI_SP = 5, // space(s) after the Request URI
- HTTP_MSG_RQVER = 6, // parsing the Request Version
- HTTP_MSG_RQLINE_END = 7, // end of request line (CR or LF)
-
- HTTP_MSG_RPBEFORE = 8, // response: leading LF, before start line
- HTTP_MSG_RPBEFORE_CR = 9, // response: leading CRLF, before start line
-
- /* these ones define a response start line */
- HTTP_MSG_RPVER = 10, // parsing the Response Version
- HTTP_MSG_RPVER_SP = 11, // space(s) after the Response Version
- HTTP_MSG_RPCODE = 12, // response code
- HTTP_MSG_RPCODE_SP = 13, // space(s) after the response code
- HTTP_MSG_RPREASON = 14, // response reason
- HTTP_MSG_RPLINE_END = 15, // end of response line (CR or LF)
-
- /* common header processing */
- HTTP_MSG_HDR_FIRST = 16, // waiting for first header or last CRLF (no LWS possible)
- HTTP_MSG_HDR_NAME = 17, // parsing header name
- HTTP_MSG_HDR_COL = 18, // parsing header colon
- HTTP_MSG_HDR_L1_SP = 19, // parsing header LWS (SP|HT) before value
- HTTP_MSG_HDR_L1_LF = 20, // parsing header LWS (LF) before value
- HTTP_MSG_HDR_L1_LWS = 21, // checking whether it's a new header or an LWS
- HTTP_MSG_HDR_VAL = 22, // parsing header value
- HTTP_MSG_HDR_L2_LF = 23, // parsing header LWS (LF) inside/after value
- HTTP_MSG_HDR_L2_LWS = 24, // checking whether it's a new header or an LWS
-
- HTTP_MSG_LAST_LF = 25, // parsing last LF
-
- /* error state : must be before HTTP_MSG_BODY so that (>=BODY) always indicates
- * that data are being processed.
- */
- HTTP_MSG_ERROR = 26, // an error occurred
- /* Body processing.
- * The state HTTP_MSG_BODY is a delimiter to know if we're waiting for headers
- * or body. All the sub-states below also indicate we're processing the body,
- * with some additional information.
- */
- HTTP_MSG_BODY = 27, // parsing body at end of headers
- HTTP_MSG_100_SENT = 28, // parsing body after a 100-Continue was sent
- HTTP_MSG_CHUNK_SIZE = 29, // parsing the chunk size (RFC7230 #4.1)
- HTTP_MSG_DATA = 30, // skipping data chunk / content-length data
- HTTP_MSG_CHUNK_CRLF = 31, // skipping CRLF after data chunk
- HTTP_MSG_TRAILERS = 32, // trailers (post-data entity headers)
- /* we enter this state when we've received the end of the current message */
- HTTP_MSG_ENDING = 33, // message end received, wait that the filters end too
- HTTP_MSG_DONE = 34, // message end received, waiting for resync or close
- HTTP_MSG_CLOSING = 35, // shutdown_w done, not all bytes sent yet
- HTTP_MSG_CLOSED = 36, // shutdown_w done, all bytes sent
- HTTP_MSG_TUNNEL = 37, // tunneled data after DONE
-} __attribute__((packed));
-
/*
* HTTP message status flags (msg->flags)
*/
@@ -323,8 +265,8 @@
* care for wrapping (no addition overflow nor subtract underflow).
*/
struct http_msg {
- enum ht_state msg_state; /* where we are in the current message parsing */
- enum ht_state err_state; /* the state where the parsing error was detected, only is MSG_ERROR */
+ enum h1_state msg_state; /* where we are in the current message parsing */
+ enum h1_state err_state; /* the state where the parsing error was detected, only is MSG_ERROR */
unsigned char flags; /* flags describing the message (HTTP version, ...) */
/* 5 bytes unused here */
struct channel *chn; /* pointer to the channel transporting the message */