]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: h1: make h1_parse_chunk_size() not depend on b_ptr() anymore
authorWilly Tarreau <w@1wt.eu>
Thu, 14 Jun 2018 13:59:05 +0000 (15:59 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 19 Jul 2018 14:23:41 +0000 (16:23 +0200)
It's similar to the previous commit so that the function doesn't rely
on buf->p anymore.

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

index d8b90cb23db53d315f180c927ed0b38be7a23dd4..b0051e3a9d6209226ad32bf166ab2f2e95ea2211 100644 (file)
@@ -175,7 +175,8 @@ static inline int h1_skip_chunk_crlf(const struct buffer *buf, int start, int st
        return bytes;
 }
 
-/* Parse the chunk size start at buf->p + start and stops before buf->p + stop.
+/* Parse the chunk size start at buf + start and stops before buf + stop. The
+ * positions are relative to the buffer's head.
  * It returns the chunk size in <res> and the amount of bytes read this way :
  *   < 0 : error at this position relative to <stop>
  *   = 0 : not enough bytes to read a complete chunk size
@@ -189,9 +190,9 @@ static inline int h1_skip_chunk_crlf(const struct buffer *buf, int start, int st
  */
 static inline int h1_parse_chunk_size(const struct buffer *buf, int start, int stop, unsigned int *res)
 {
-       const char *ptr = b_ptr(buf, start);
+       const char *ptr = b_peek(buf, start);
        const char *ptr_old = ptr;
-       const char *end = buf->data + buf->size;
+       const char *end = b_wrap(buf);
        unsigned int chunk = 0;
 
        stop -= start; // bytes left
index 98c97d8bbba6972a03efe21d7656ffe0c63ce556..e75a2ba6470591c946e695a872887aea814cab17 100644 (file)
@@ -3197,8 +3197,7 @@ static size_t h2s_frt_make_resp_data(struct h2s *h2s, struct buffer *buf, size_t
 
                if (h1m->state == HTTP_MSG_CHUNK_SIZE) {
                        unsigned int chunk;
-                       // FIXME: this one still uses the old buffer API and ignores <ofs>
-                       ret = h1_parse_chunk_size(buf, -max, 0, &chunk);
+                       ret = h1_parse_chunk_size(buf, ofs, ofs + max, &chunk);
                        if (!ret)
                                goto end;
 
index 3904b634a0232c503e9a51f9ad25cb1f0c331eac..78e0badd5f1fdabfab1367832929cf54292bba54 100644 (file)
@@ -4142,7 +4142,7 @@ int http_wait_for_request_body(struct stream *s, struct channel *req, int an_bit
                 * TRAILERS state.
                 */
                unsigned int chunk;
-               int ret = h1_parse_chunk_size(req->buf, msg->next, req->buf->i, &chunk);
+               int ret = h1_parse_chunk_size(req->buf, co_data(req) + msg->next, b_data(req->buf), &chunk);
 
                if (!ret)
                        goto missing_data;
@@ -6371,7 +6371,7 @@ http_msg_forward_chunked_body(struct stream *s, struct http_msg *msg)
                         * then set ->next to point to the body and switch to
                         * DATA or TRAILERS state.
                         */
-                       ret = h1_parse_chunk_size(chn->buf, msg->next, chn->buf->i, &chunk);
+                       ret = h1_parse_chunk_size(chn->buf, co_data(chn) + msg->next, b_data(chn->buf), &chunk);
                        if (ret == 0)
                                goto missing_data_or_waiting;
                        if (ret < 0) {