When the decompressed data do not fit in the buffer, the remaining ones
are emitted on a next call. But once the first part was sent, the
channel buffer may have been released, and in this case nothing could be
emitted and the message was stuck. This happens with requests whose EOM
is carried by the last DATA block (content-length in H1, or H2) when
this block is decompressed into more than a buffer, e.g. 30kB of text:
the client gets a 504.
Now the buffer is allocated when the filter still has something to emit.
Since the HTX message seen by the caller changes in this case, it is now
retrieved again after the call to the filters, in both
http_request_forward_body() and http_response_forward_body(). The filter
was introduced in 3.5-dev6, so no backport is needed.
goto end;
}
+ /* the buffer may have been released while data are still to be emitted */
+ if (!b_size(&chn->buf) && (st->decomp_ctx->drain_len || (st->flags & DECOMP_STATE_EOM_SEEN))) {
+ if (!channel_alloc_buffer(chn, &s->buffer_wait))
+ goto end;
+ htx = htx_from_buf(&chn->buf);
+ }
+
htxret = htx_find_offset(htx, offset);
offset = htxret.ret;
blk = htxret.blk;
ret = flt_http_payload(s, msg, htx->data);
if (ret < 0)
goto return_bad_req;
+ /* a filter may have allocated the buffer */
+ htx = htxbuf(&req->buf);
c_adv(req, ret);
}
else {
ret = flt_http_payload(s, msg, htx->data);
if (ret < 0)
goto return_bad_res;
+ /* a filter may have allocated the buffer */
+ htx = htxbuf(&res->buf);
c_adv(res, ret);
}
else {