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.
This commit is contained in:
Willy Tarreau 2017-09-21 11:46:43 +02:00
parent b28925675d
commit 4093a4dc01
2 changed files with 27 additions and 0 deletions

View 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 */

View 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 */