]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: h1: add struct h1m for basic HTTP/1 messages
authorWilly Tarreau <w@1wt.eu>
Thu, 21 Sep 2017 09:46:43 +0000 (11:46 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 22 Oct 2017 07:54:14 +0000 (09:54 +0200)
This one is much simpler than http_msg and will be used in the HTTP
parsers involved in the H2 to H1 gateway.

include/proto/h1.h
include/types/h1.h

index 8a0e265419caeb994956b756e02626fdafc0a052..6bd753776affb9c3330cbf840e1883e1a6d3c2d7 100644 (file)
@@ -267,5 +267,16 @@ static inline int h1_parse_chunk_size(const struct buffer *buf, int start, int s
        return -buffer_count(buf, ptr, ptr_stop);
 }
 
+/* initializes an H1 message */
+static inline struct h1m *h1m_init(struct h1m *h1m)
+{
+       h1m->state = HTTP_MSG_RQBEFORE;
+       h1m->flags = 0;
+       h1m->curr_len = 0;
+       h1m->body_len = 0;
+       h1m->err_pos = 0;
+       h1m->err_state = 0;
+       return h1m;
+}
 
 #endif /* _PROTO_H1_H */
index 8a146c3caadaa70e4e285231cac293bdba22d00b..230102c008b92f3f134fbe4272fd1c4d4c9618ec 100644 (file)
@@ -82,4 +82,20 @@ enum h1_state {
 } __attribute__((packed));
 
 
+/* HTTP/1 message flags (32 bit), for use in h1m->flags only */
+#define H1_MF_NONE              0x00000000
+#define H1_MF_CLEN              0x00000001 // content-length present
+#define H1_MF_CHNK              0x00000002 // chunk present, exclusive with c-l
+
+
+/* basic HTTP/1 message state for use in parsers */
+struct h1m {
+       enum h1_state state;        // H1 message state (HTTP_MSG_*)
+       uint32_t flags;             // H1 message flags (H1_MF_*)
+       uint64_t curr_len;          // content-length or last chunk length
+       uint64_t body_len;          // total known size of the body length
+       int err_pos;                // position in the byte stream of the first error (H1 or H2)
+       int err_state;              // state where the first error was met (H1 or H2)
+};
+
 #endif /* _TYPES_H1_H */