BUG/MINOR: httpclient: remove the UNUSED block when parsing headers
Remove the UNUSED blocks when iterating on headers, we should not stop
when encountering one. We should only stop iterating once we found the
EOH block. It doesn't provoke a problem, since we don't manipulates
the headers before treating them, but it could evolve in the future.
Must be backported to 2.5.
diff --git a/src/http_client.c b/src/http_client.c
index f17e805..94b192a 100644
--- a/src/http_client.c
+++ b/src/http_client.c
@@ -787,24 +787,29 @@
enum htx_blk_type type = htx_get_blk_type(blk);
uint32_t sz = htx_get_blksz(blk);
+ if (type == HTX_BLK_UNUSED) {
+ c_rew(res, sz);
+ htx_remove_blk(htx, blk);
+ }
+
+ if (type == HTX_BLK_HDR) {
+ hdrs[hdr_num].n = istdup(htx_get_blk_name(htx, blk));
+ hdrs[hdr_num].v = istdup(htx_get_blk_value(htx, blk));
+ if (!isttest(hdrs[hdr_num].v) || !isttest(hdrs[hdr_num].n))
+ goto end;
+ c_rew(res, sz);
+ htx_remove_blk(htx, blk);
+ hdr_num++;
+ }
+
+ /* create a NULL end of array and leave the loop */
if (type == HTX_BLK_EOH) {
hdrs[hdr_num].n = IST_NULL;
hdrs[hdr_num].v = IST_NULL;
- co_set_data(res, co_data(res) - sz);
+ c_rew(res, sz);
htx_remove_blk(htx, blk);
break;
}
-
- if (type != HTX_BLK_HDR)
- break;
-
- hdrs[hdr_num].n = istdup(htx_get_blk_name(htx, blk));
- hdrs[hdr_num].v = istdup(htx_get_blk_value(htx, blk));
- if (!isttest(hdrs[hdr_num].v) || !isttest(hdrs[hdr_num].n))
- goto end;
- co_set_data(res, co_data(res) - sz);
- htx_remove_blk(htx, blk);
- hdr_num++;
}
if (hdr_num) {