[core] short-circuit if response body recv w/ hdrs (fixes #3111)

short-circuit if response body completely received with response headers

x-ref:
  "HTTP/2 requests sometimes take very long (missing last chunk)"
  https://redmine.lighttpd.net/issues/3111
This commit is contained in:
Glenn Strauss 2021-10-17 19:38:20 -04:00
parent 71544129f9
commit 0757d71e14
1 changed files with 8 additions and 3 deletions

View File

@ -1329,15 +1329,20 @@ handler_t http_response_read(request_st * const r, http_response_opts * const op
/* accumulate response in b until headers completed (or error)*/
if (r->resp_body_started) {
buffer_clear(b);
/* check if Content-Length provided and response body received
* (done here instead of http_response_process_headers() since
* backends which set opts->parse() might handle differently)*/
if (0 == r->resp_body_scratchpad)
r->resp_body_finished = 1;
/* enable simple accumulation of small reads in some situations
* no Content-Length (will read to EOF)
* Content-Length (will read until r->resp_body_scratchpad == 0)
* not chunked-encoding
* not bufmin streaming
* (no custom parse routine set for opts->parse()) */
if (!r->resp_decode_chunked /* && NULL == opts->parse */
&& !(r->conf.stream_response_body
& FDEVENT_STREAM_RESPONSE_BUFMIN))
else if (!r->resp_decode_chunked /* && NULL == opts->parse */
&& !(r->conf.stream_response_body
& FDEVENT_STREAM_RESPONSE_BUFMIN))
opts->simple_accum = 1;
}
} else {