diff options
author | Zhidao HONG <z.hong@f5.com> | 2024-06-11 10:18:44 +0800 |
---|---|---|
committer | Zhidao HONG <z.hong@f5.com> | 2024-06-20 10:39:17 +0800 |
commit | 999d274837273e354efc05075c0b012b81902ef1 (patch) | |
tree | a5b349d73aa1f992155482efb5e984343ebd8239 /src/nxt_http_chunk_parse.c | |
parent | 57a0f94efb2550ea1c6cb593b2b968e022c89346 (diff) | |
download | unit-999d274837273e354efc05075c0b012b81902ef1.tar.gz unit-999d274837273e354efc05075c0b012b81902ef1.tar.bz2 |
http: Move chunked buffer pos pointer while parsing
Previously, Unit didn't move the buffer pointer when parsing chunked
data because the buffer was not used after sent. It's used for upstream
response. With the new requirement to support request chunked body,
the buffer might be used for pipeline request, so it's necessary to move
the pos pointer while parsing.
Reviewed-by: Andrew Clayton <a.clayton@nginx.com>
Diffstat (limited to 'src/nxt_http_chunk_parse.c')
-rw-r--r-- | src/nxt_http_chunk_parse.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/nxt_http_chunk_parse.c b/src/nxt_http_chunk_parse.c index b60bc801..a43ce75b 100644 --- a/src/nxt_http_chunk_parse.c +++ b/src/nxt_http_chunk_parse.c @@ -48,9 +48,7 @@ nxt_http_chunk_parse(nxt_task_t *task, nxt_http_chunk_parse_t *hcp, for (b = in; b != NULL; b = next) { - hcp->pos = b->mem.pos; - - while (hcp->pos < b->mem.free) { + while (b->mem.pos < b->mem.free) { /* * The sw_chunk state is tested outside the switch * to preserve hcp->pos and to not touch memory. @@ -76,7 +74,7 @@ nxt_http_chunk_parse(nxt_task_t *task, nxt_http_chunk_parse_t *hcp, /* ret == NXT_HTTP_CHUNK_END */ } - ch = *hcp->pos++; + ch = *b->mem.pos++; switch (state) { @@ -203,7 +201,7 @@ nxt_http_chunk_buffer(nxt_http_chunk_parse_t *hcp, nxt_buf_t ***tail, size_t size; nxt_buf_t *b; - p = hcp->pos; + p = in->mem.pos; size = in->mem.free - p; b = nxt_buf_mem_alloc(hcp->mem_pool, 0, 0); @@ -224,7 +222,7 @@ nxt_http_chunk_buffer(nxt_http_chunk_parse_t *hcp, nxt_buf_t ***tail, if (hcp->chunk_size < size) { p += hcp->chunk_size; - hcp->pos = p; + in->mem.pos = p; b->mem.free = p; b->mem.end = p; |