MINOR: h1: add struct h1m for basic HTTP/1 messages
This one is much simpler than http_msg and will be used in the HTTP
parsers involved in the H2 to H1 gateway.
diff --git a/include/proto/h1.h b/include/proto/h1.h
index 8a0e265..6bd7537 100644
--- a/include/proto/h1.h
+++ b/include/proto/h1.h
@@ -267,5 +267,16 @@
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 */
diff --git a/include/types/h1.h b/include/types/h1.h
index 8a146c3..230102c 100644
--- a/include/types/h1.h
+++ b/include/types/h1.h
@@ -82,4 +82,20 @@
} __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 */