]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
REORG: h1: move the h1_state definition to proto_http
authorWilly Tarreau <w@1wt.eu>
Tue, 11 Dec 2018 10:04:56 +0000 (11:04 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 11 Dec 2018 16:15:13 +0000 (17:15 +0100)
This is the legacy HTTP/1 state, it's never used from within h1 users,
let's move it to proto_http with the rest of the legacy code.

include/proto/h1.h
include/proto/proto_http.h
include/types/h1.h
include/types/hlua.h
include/types/proto_http.h

index 68ba106f296cb2f6c1f55e360537e9988c1b76cd..7d8ea61b570d4edee6074981987b696e78d36ead 100644 (file)
@@ -39,52 +39,6 @@ int h1_parse_cont_len_header(struct h1m *h1m, struct ist *value);
 void h1_parse_xfer_enc_header(struct h1m *h1m, struct ist value);
 void h1_parse_connection_header(struct h1m *h1m, struct ist value);
 
-/* for debugging, reports the HTTP/1 message state name (legacy version) */
-static inline const char *h1_msg_state_str(enum h1_state msg_state)
-{
-       switch (msg_state) {
-       case HTTP_MSG_RQBEFORE:    return "MSG_RQBEFORE";
-       case HTTP_MSG_RQBEFORE_CR: return "MSG_RQBEFORE_CR";
-       case HTTP_MSG_RQMETH:      return "MSG_RQMETH";
-       case HTTP_MSG_RQMETH_SP:   return "MSG_RQMETH_SP";
-       case HTTP_MSG_RQURI:       return "MSG_RQURI";
-       case HTTP_MSG_RQURI_SP:    return "MSG_RQURI_SP";
-       case HTTP_MSG_RQVER:       return "MSG_RQVER";
-       case HTTP_MSG_RQLINE_END:  return "MSG_RQLINE_END";
-       case HTTP_MSG_RPBEFORE:    return "MSG_RPBEFORE";
-       case HTTP_MSG_RPBEFORE_CR: return "MSG_RPBEFORE_CR";
-       case HTTP_MSG_RPVER:       return "MSG_RPVER";
-       case HTTP_MSG_RPVER_SP:    return "MSG_RPVER_SP";
-       case HTTP_MSG_RPCODE:      return "MSG_RPCODE";
-       case HTTP_MSG_RPCODE_SP:   return "MSG_RPCODE_SP";
-       case HTTP_MSG_RPREASON:    return "MSG_RPREASON";
-       case HTTP_MSG_RPLINE_END:  return "MSG_RPLINE_END";
-       case HTTP_MSG_HDR_FIRST:   return "MSG_HDR_FIRST";
-       case HTTP_MSG_HDR_NAME:    return "MSG_HDR_NAME";
-       case HTTP_MSG_HDR_COL:     return "MSG_HDR_COL";
-       case HTTP_MSG_HDR_L1_SP:   return "MSG_HDR_L1_SP";
-       case HTTP_MSG_HDR_L1_LF:   return "MSG_HDR_L1_LF";
-       case HTTP_MSG_HDR_L1_LWS:  return "MSG_HDR_L1_LWS";
-       case HTTP_MSG_HDR_VAL:     return "MSG_HDR_VAL";
-       case HTTP_MSG_HDR_L2_LF:   return "MSG_HDR_L2_LF";
-       case HTTP_MSG_HDR_L2_LWS:  return "MSG_HDR_L2_LWS";
-       case HTTP_MSG_LAST_LF:     return "MSG_LAST_LF";
-       case HTTP_MSG_ERROR:       return "MSG_ERROR";
-       case HTTP_MSG_BODY:        return "MSG_BODY";
-       case HTTP_MSG_100_SENT:    return "MSG_100_SENT";
-       case HTTP_MSG_CHUNK_SIZE:  return "MSG_CHUNK_SIZE";
-       case HTTP_MSG_DATA:        return "MSG_DATA";
-       case HTTP_MSG_CHUNK_CRLF:  return "MSG_CHUNK_CRLF";
-       case HTTP_MSG_TRAILERS:    return "MSG_TRAILERS";
-       case HTTP_MSG_ENDING:      return "MSG_ENDING";
-       case HTTP_MSG_DONE:        return "MSG_DONE";
-       case HTTP_MSG_CLOSING:     return "MSG_CLOSING";
-       case HTTP_MSG_CLOSED:      return "MSG_CLOSED";
-       case HTTP_MSG_TUNNEL:      return "MSG_TUNNEL";
-       default:                   return "MSG_??????";
-       }
-}
-
 /* for debugging, reports the HTTP/1 message state name */
 static inline const char *h1m_state_str(enum h1m_state msg_state)
 {
index 329e64154cd48a9301f05f304e1fe6e4c4432fbb..db85fae8c197fdfc2d2f1731895674ed26d57598 100644 (file)
@@ -223,6 +223,52 @@ static inline int http_body_bytes(const struct http_msg *msg)
        return len;
 }
 
+/* for debugging, reports the HTTP/1 message state name (legacy version) */
+static inline const char *h1_msg_state_str(enum h1_state msg_state)
+{
+       switch (msg_state) {
+       case HTTP_MSG_RQBEFORE:    return "MSG_RQBEFORE";
+       case HTTP_MSG_RQBEFORE_CR: return "MSG_RQBEFORE_CR";
+       case HTTP_MSG_RQMETH:      return "MSG_RQMETH";
+       case HTTP_MSG_RQMETH_SP:   return "MSG_RQMETH_SP";
+       case HTTP_MSG_RQURI:       return "MSG_RQURI";
+       case HTTP_MSG_RQURI_SP:    return "MSG_RQURI_SP";
+       case HTTP_MSG_RQVER:       return "MSG_RQVER";
+       case HTTP_MSG_RQLINE_END:  return "MSG_RQLINE_END";
+       case HTTP_MSG_RPBEFORE:    return "MSG_RPBEFORE";
+       case HTTP_MSG_RPBEFORE_CR: return "MSG_RPBEFORE_CR";
+       case HTTP_MSG_RPVER:       return "MSG_RPVER";
+       case HTTP_MSG_RPVER_SP:    return "MSG_RPVER_SP";
+       case HTTP_MSG_RPCODE:      return "MSG_RPCODE";
+       case HTTP_MSG_RPCODE_SP:   return "MSG_RPCODE_SP";
+       case HTTP_MSG_RPREASON:    return "MSG_RPREASON";
+       case HTTP_MSG_RPLINE_END:  return "MSG_RPLINE_END";
+       case HTTP_MSG_HDR_FIRST:   return "MSG_HDR_FIRST";
+       case HTTP_MSG_HDR_NAME:    return "MSG_HDR_NAME";
+       case HTTP_MSG_HDR_COL:     return "MSG_HDR_COL";
+       case HTTP_MSG_HDR_L1_SP:   return "MSG_HDR_L1_SP";
+       case HTTP_MSG_HDR_L1_LF:   return "MSG_HDR_L1_LF";
+       case HTTP_MSG_HDR_L1_LWS:  return "MSG_HDR_L1_LWS";
+       case HTTP_MSG_HDR_VAL:     return "MSG_HDR_VAL";
+       case HTTP_MSG_HDR_L2_LF:   return "MSG_HDR_L2_LF";
+       case HTTP_MSG_HDR_L2_LWS:  return "MSG_HDR_L2_LWS";
+       case HTTP_MSG_LAST_LF:     return "MSG_LAST_LF";
+       case HTTP_MSG_ERROR:       return "MSG_ERROR";
+       case HTTP_MSG_BODY:        return "MSG_BODY";
+       case HTTP_MSG_100_SENT:    return "MSG_100_SENT";
+       case HTTP_MSG_CHUNK_SIZE:  return "MSG_CHUNK_SIZE";
+       case HTTP_MSG_DATA:        return "MSG_DATA";
+       case HTTP_MSG_CHUNK_CRLF:  return "MSG_CHUNK_CRLF";
+       case HTTP_MSG_TRAILERS:    return "MSG_TRAILERS";
+       case HTTP_MSG_ENDING:      return "MSG_ENDING";
+       case HTTP_MSG_DONE:        return "MSG_DONE";
+       case HTTP_MSG_CLOSING:     return "MSG_CLOSING";
+       case HTTP_MSG_CLOSED:      return "MSG_CLOSED";
+       case HTTP_MSG_TUNNEL:      return "MSG_TUNNEL";
+       default:                   return "MSG_??????";
+       }
+}
+
 #endif /* _PROTO_PROTO_HTTP_H */
 
 /*
index d3e44265307d807ab046961cbb63637c7a831bf1..840c8890012c8f624731844e2fabf8e766f58e28 100644 (file)
 #include <common/http.h>
 #include <common/ist.h>
 
-/* Legacy version of the HTTP/1 message state, used by the channels, should
- * ultimately be removed.
- */
-enum h1_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));
-
-
 /* Possible states while parsing HTTP/1 messages (request|response) */
 enum h1m_state {
        H1_MSG_RQBEFORE     =  0, // request: leading LF, before start line
index b9c819f26edef5d4c568c8f8f574d412b6eb22fd..f9709bbbb1c3ea674bfa9ff7006751aebf1b61ad 100644 (file)
@@ -8,7 +8,7 @@
 
 #include <common/xref.h>
 
-#include <types/h1.h>
+#include <types/proto_http.h>
 #include <types/proxy.h>
 #include <types/server.h>
 
index 9e8bbd5d183050947bc85f1b1a3198a2a810c747..972a6d33088734be4bd40654b20e8edd80fba17e 100644 (file)
@@ -197,6 +197,68 @@ enum {
        STAT_STATUS_SIZE
 };
 
+/* Legacy version of the HTTP/1 message state, used by the channels, should
+ * ultimately be removed.
+ */
+enum h1_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));
+
+
 /* This is an HTTP message, as described in RFC7230. It can be either a request
  * message or a response message.
  *