MINOR: h1: add the restart offsets into struct h1m

Currently the only user of struct h1m is the h2 mux when it has to parse
an H1 message coming from the channel. Unfortunately this is not enough
to efficiently parse HTTP/1 messages like those coming from the network
as we don't want to restart from scratch at every byte received.

This patch reintroduces the "next" offset into the H1 message so that any
H1 parser can use it to restart when called with a state that is not the
initial state.
This commit is contained in:
Willy Tarreau 2018-09-11 11:51:31 +02:00
parent 801250e07d
commit b3b0152b6f
2 changed files with 2 additions and 0 deletions

View File

@ -309,6 +309,7 @@ static inline int h1_parse_chunk_size(const struct buffer *buf, int start, int s
static inline struct h1m *h1m_init(struct h1m *h1m)
{
h1m->state = H1_MSG_RQBEFORE;
h1m->next = 0;
h1m->status = 0;
h1m->flags = 0;
h1m->curr_len = 0;

View File

@ -158,6 +158,7 @@ struct h1m {
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
uint32_t next; // next byte to parse, relative to buffer's head
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)
};