When a response is stored, http_action_store_cache() copies all the
blocks of the headers, including the unused ones left by a removed
header, such as after "http-response del-header" or "set-header" on a
header which is not the last one. When the object is served, the applet
tries to add this empty block again, which htx_add_blk() refuses since
commit
58ce50527 ("MINOR: htx: never create, leave nor accept an empty
HTX block"), so each cache hit ends with a 500.
Skip the unused blocks when storing the headers. This can be tested
with "http-response del-header X-Test" before "http-response
cache-store", and a server sending X-Test followed by another header:
the second request for the same URL gets a 500.
This should fix github issue #3616. It must be backported to 3.5.
uint32_t sz = htx_get_blksz(blk);
struct ist header_name = IST_NULL;
+ if (type == HTX_BLK_UNUSED)
+ continue;
+
/* The cache serves its copies with a freshly computed
* Age, so the Age headers are not stored. They are left
* in the response which is forwarded as-is.