]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: h1: provide a distinct init() function for request and response
authorWilly Tarreau <w@1wt.eu>
Tue, 11 Sep 2018 11:51:19 +0000 (13:51 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 12 Sep 2018 15:38:25 +0000 (17:38 +0200)
h1m_init() used to handle response only since it was used by the H1
client code. Let's have one init per direction.

include/proto/h1.h
src/mux_h2.c

index 472f4e7655b5739def291bc2dc8829f6113aab3c..365d06999dcfeea3e10333bc9d72c7b6a5bb9c7f 100644 (file)
@@ -300,8 +300,8 @@ static inline int h1_parse_chunk_size(const struct buffer *buf, int start, int s
        return -stop;
 }
 
-/* initializes an H1 message */
-static inline struct h1m *h1m_init(struct h1m *h1m)
+/* initializes an H1 message for a request */
+static inline struct h1m *h1m_init_req(struct h1m *h1m)
 {
        h1m->state = H1_MSG_RQBEFORE;
        h1m->next = 0;
@@ -314,4 +314,18 @@ static inline struct h1m *h1m_init(struct h1m *h1m)
        return h1m;
 }
 
+/* initializes an H1 message for a response */
+static inline struct h1m *h1m_init_res(struct h1m *h1m)
+{
+       h1m->state = H1_MSG_RPBEFORE;
+       h1m->next = 0;
+       h1m->status = 0;
+       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 */
index 595d66b6107b91e8084163aeecbde98f02e4ff15..c1dad4c556cf1848dee7a20d5efd302ff9a2fb4c 100644 (file)
@@ -690,8 +690,8 @@ static struct h2s *h2c_stream_new(struct h2c *h2c, int id)
        h2s->errcode   = H2_ERR_NO_ERROR;
        h2s->st        = H2_SS_IDLE;
        h2s->rxbuf     = BUF_NULL;
-       h1m_init(&h2s->req);
-       h1m_init(&h2s->res);
+       h1m_init_req(&h2s->req);
+       h1m_init_res(&h2s->res);
        h2s->by_id.key = h2s->id = id;
        h2c->max_id    = id;
 
@@ -3231,9 +3231,7 @@ static size_t h2s_frt_make_resp_headers(struct h2s *h2s, const struct buffer *bu
        }
        else if (h1m->status >= 100 && h1m->status < 200) {
                /* we'll let the caller check if it has more headers to send */
-               h1m->state = H1_MSG_RPBEFORE;
-               h1m->status = 0;
-               h1m->flags = 0;
+               h1m_init_res(h1m);
                goto end;
        }
        else