From b3b0152b6fd0e09f96f9427e35d3f9832460d901 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Tue, 11 Sep 2018 11:51:31 +0200 Subject: [PATCH] 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. --- include/proto/h1.h | 1 + include/types/h1.h | 1 + 2 files changed, 2 insertions(+) diff --git a/include/proto/h1.h b/include/proto/h1.h index 22b5c6e89..7fd32241b 100644 --- a/include/proto/h1.h +++ b/include/proto/h1.h @@ -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; diff --git a/include/types/h1.h b/include/types/h1.h index 85876086f..7d9c12e90 100644 --- a/include/types/h1.h +++ b/include/types/h1.h @@ -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) };