mirror of
https://github.com/nginx/nginx.git
synced 2025-06-07 17:52:38 +08:00
"gzip_vary on" always sends "Vary: Accept-Encoding" header
This commit is contained in:
parent
77c287f35d
commit
c49ed61376
@ -204,12 +204,11 @@ static ngx_http_output_body_filter_pt ngx_http_next_body_filter;
|
|||||||
static ngx_int_t
|
static ngx_int_t
|
||||||
ngx_http_gzip_header_filter(ngx_http_request_t *r)
|
ngx_http_gzip_header_filter(ngx_http_request_t *r)
|
||||||
{
|
{
|
||||||
ngx_str_t *type;
|
ngx_str_t *type;
|
||||||
ngx_uint_t i;
|
ngx_uint_t i;
|
||||||
ngx_table_elt_t *h;
|
ngx_table_elt_t *h;
|
||||||
ngx_http_gzip_ctx_t *ctx;
|
ngx_http_gzip_ctx_t *ctx;
|
||||||
ngx_http_gzip_conf_t *conf;
|
ngx_http_gzip_conf_t *conf;
|
||||||
ngx_http_core_loc_conf_t *clcf;
|
|
||||||
|
|
||||||
conf = ngx_http_get_module_loc_conf(r, ngx_http_gzip_filter_module);
|
conf = ngx_http_get_module_loc_conf(r, ngx_http_gzip_filter_module);
|
||||||
|
|
||||||
@ -264,21 +263,6 @@ found:
|
|||||||
|
|
||||||
r->headers_out.content_encoding = h;
|
r->headers_out.content_encoding = h;
|
||||||
|
|
||||||
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
|
|
||||||
|
|
||||||
if (clcf->gzip_vary) {
|
|
||||||
h = ngx_list_push(&r->headers_out.headers);
|
|
||||||
if (h == NULL) {
|
|
||||||
return NGX_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
h->hash = 1;
|
|
||||||
h->key.len = sizeof("Vary") - 1;
|
|
||||||
h->key.data = (u_char *) "Vary";
|
|
||||||
h->value.len = sizeof("Accept-Encoding") - 1;
|
|
||||||
h->value.data = (u_char *) "Accept-Encoding";
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx->length = r->headers_out.content_length_n;
|
ctx->length = r->headers_out.content_length_n;
|
||||||
|
|
||||||
r->main_filter_need_in_memory = 1;
|
r->main_filter_need_in_memory = 1;
|
||||||
|
@ -203,19 +203,6 @@ ngx_http_gzip_static_handler(ngx_http_request_t *r)
|
|||||||
|
|
||||||
r->headers_out.content_encoding = h;
|
r->headers_out.content_encoding = h;
|
||||||
|
|
||||||
if (clcf->gzip_vary) {
|
|
||||||
h = ngx_list_push(&r->headers_out.headers);
|
|
||||||
if (h == NULL) {
|
|
||||||
return NGX_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
h->hash = 1;
|
|
||||||
h->key.len = sizeof("Vary") - 1;
|
|
||||||
h->key.data = (u_char *) "Vary";
|
|
||||||
h->value.len = sizeof("Accept-Encoding") - 1;
|
|
||||||
h->value.data = (u_char *) "Accept-Encoding";
|
|
||||||
}
|
|
||||||
|
|
||||||
/* we need to allocate all before the header would be sent */
|
/* we need to allocate all before the header would be sent */
|
||||||
|
|
||||||
b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t));
|
b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t));
|
||||||
|
@ -347,6 +347,10 @@ ngx_http_header_filter(ngx_http_request_t *r)
|
|||||||
len += sizeof("Connection: closed" CRLF) - 1;
|
len += sizeof("Connection: closed" CRLF) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (r->gzip && clcf->gzip_vary) {
|
||||||
|
len += sizeof("Vary: Accept-Encoding" CRLF) - 1;
|
||||||
|
}
|
||||||
|
|
||||||
part = &r->headers_out.headers.part;
|
part = &r->headers_out.headers.part;
|
||||||
header = part->elts;
|
header = part->elts;
|
||||||
|
|
||||||
@ -516,6 +520,11 @@ ngx_http_header_filter(ngx_http_request_t *r)
|
|||||||
sizeof("Connection: close" CRLF) - 1);
|
sizeof("Connection: close" CRLF) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (r->gzip && clcf->gzip_vary) {
|
||||||
|
b->last = ngx_cpymem(b->last, "Vary: Accept-Encoding" CRLF,
|
||||||
|
sizeof("Vary: Accept-Encoding" CRLF) - 1);
|
||||||
|
}
|
||||||
|
|
||||||
part = &r->headers_out.headers.part;
|
part = &r->headers_out.headers.part;
|
||||||
header = part->elts;
|
header = part->elts;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user