Fix "header too long" error
Vadim Fedorenko
vadimjunk at gmail.com
Tue Jan 16 11:57:40 UTC 2018
# HG changeset patch
# User Vadim Fedorenko <vfedorenko at yandex-team.ru>
# Date 1516103689 -10800
# Tue Jan 16 14:54:49 2018 +0300
# Node ID deaa364977488f3390d48306c34dc80961e54e14
# Parent fbf6a421212b291cbacfcfc503173c0168449165
Fix "header too long" error
This error occurs in rare cases when cached file with different "Vary"
header value have headers length more than main cache file and main
cache file can be used without revalidation (ngx_file_cache_exists
finds file node and rewrites c->body_start on first read). Fix saves
buffer size derived from proxy_buffer parameter.
diff -r fbf6a421212b -r deaa36497748 src/http/ngx_http_file_cache.c
--- a/src/http/ngx_http_file_cache.c Fri Jan 12 02:27:18 2018 +0300
+++ b/src/http/ngx_http_file_cache.c Tue Jan 16 14:54:49 2018 +0300
@@ -271,6 +271,7 @@
ngx_open_file_info_t of;
ngx_http_file_cache_t *cache;
ngx_http_core_loc_conf_t *clcf;
+ size_t buffer_size;
c = r->cache;
@@ -294,6 +295,12 @@
cln->data = c;
}
+ /* save buffer_size because ngx_http_file_cache_exists
+ * can overwrite c->body_start
+ */
+
+ buffer_size = c->body_start;
+
rc = ngx_http_file_cache_exists(cache, c);
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
@@ -382,7 +389,7 @@
c->length = of.size;
c->fs_size = (of.fs_size + cache->bsize - 1) / cache->bsize;
- c->buf = ngx_create_temp_buf(r->pool, c->body_start);
+ c->buf = ngx_create_temp_buf(r->pool, buffer_size);
if (c->buf == NULL) {
return NGX_ERROR;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20180116/9875a403/attachment.html>
More information about the nginx-devel
mailing list