]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: h1: add the restart offsets into struct h1m
authorWilly Tarreau <w@1wt.eu>
Tue, 11 Sep 2018 09:51:31 +0000 (11:51 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 12 Sep 2018 15:38:25 +0000 (17:38 +0200)
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
include/types/h1.h

index 22b5c6e89956d03593090a4f5176e8bf470ab05c..7fd32241b16c78a1ab58b463dc97670d773a43fd 100644 (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;
index 85876086f01133ea1e806aa14b458f15935f1064..7d9c12e901e0d94f8b4f688eac71dd8a633077ca 100644 (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)
 };