summaryrefslogtreecommitdiff
path: root/src/http-header-glue.c
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2021-09-29 12:51:35 -0400
committerGlenn Strauss <gstrauss@gluelogic.com>2021-10-01 06:39:47 -0400
commite4cf6998a14c43e4a60d330cc67d93967f941ca1 (patch)
tree8e4669a93d604c38958ac23fca09eabde917760f /src/http-header-glue.c
parentb5d41691560540922a615a9b1d3e86f7a0c3a233 (diff)
downloadlighttpd-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.c11
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 */