diff options
author | Glenn Strauss <gstrauss@gluelogic.com> | 2021-09-29 12:51:35 -0400 |
---|---|---|
committer | Glenn Strauss <gstrauss@gluelogic.com> | 2021-10-01 06:39:47 -0400 |
commit | e4cf6998a14c43e4a60d330cc67d93967f941ca1 (patch) | |
tree | 8e4669a93d604c38958ac23fca09eabde917760f /src/http-header-glue.c | |
parent | b5d41691560540922a615a9b1d3e86f7a0c3a233 (diff) | |
download | lighttpd-git-e4cf6998a14c43e4a60d330cc67d93967f941ca1.tar.gz |
[core] limit initial response header backend read
Diffstat (limited to 'src/http-header-glue.c')
-rw-r--r-- | src/http-header-glue.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/http-header-glue.c b/src/http-header-glue.c index d38971a2..d56f5840 100644 --- a/src/http-header-glue.c +++ b/src/http-header-glue.c @@ -1212,6 +1212,14 @@ handler_t http_response_read(request_st * const r, http_response_opts * const op toread = 4095 - blen; else if (toread > opts->max_per_read) toread = opts->max_per_read; + /* reduce amount read for response headers to reduce extra data + * copying for initial data following response headers + * (see http_response_parse_headers()) + * (This seems reasonable to do even if opts->parse is set) + * (default chunk buffer is 8k; typical response headers < 8k) + * (An alternative might be the opposite: read extra, e.g. 128k, + * if data available, in order to write to temp files sooner)*/ + if (toread > 8192 && !r->resp_body_started) toread = 8192; } else if (0 == toread) { #if 0 @@ -1364,7 +1372,8 @@ handler_t http_response_read(request_st * const r, http_response_opts * const op break; } } - } while (0); /*(extra logic might benefit systems without FIONREAD)*/ + } while (!r->resp_body_started); /*(loop to read large response headers)*/ + /*while (0);*//*(extra logic might benefit systems without FIONREAD)*/ /*while ((size_t)n == avail && (total += (size_t)n) < opts->max_per_read);*/ /* else emptied kernel read buffer or partial read or reached read limit */ |