Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 'Vary' header #98

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions static/ngx_http_brotli_static_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,15 @@ static ngx_int_t handler(ngx_http_request_t* req) {

/* Get configuration and check if module is disabled. */
cfg = ngx_http_get_module_loc_conf(req, ngx_http_brotli_static_module);
if (cfg->enable == NGX_HTTP_BROTLI_STATIC_OFF) return NGX_DECLINED;
if (cfg->enable == NGX_HTTP_BROTLI_STATIC_OFF) {
return NGX_DECLINED;
}

if (cfg->enable == NGX_HTTP_BROTLI_STATIC_ALWAYS) {
/* Ignore request properties (e.g. Accept-Encoding). */
} else {
/* NGX_HTTP_BROTLI_STATIC_ON */
req->gzip_vary = 1;
if (cfg->enable == NGX_HTTP_BROTLI_STATIC_ON) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is preferrable to have least-modification concise change. Just remove req->gzip_vary = 1 line

rc = check_eligility(req);
if (rc != NGX_OK) return NGX_DECLINED;
} else {
/* always */
}

/* Get path and append the suffix. */
Expand Down Expand Up @@ -227,6 +227,14 @@ static ngx_int_t handler(ngx_http_request_t* req) {
return NGX_DECLINED;
}

if (cfg->enable == NGX_HTTP_BROTLI_STATIC_ON) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this should be conditional here.
General rule - if compressed entry is going to be server - it must have vary header.

req->gzip_vary = 1;

if (rc != NGX_OK) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rc can not be != NGX_OK here

return NGX_DECLINED;
}
}

/* So far so good. */
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, log, 0, "http static fd: %d",
file_info.fd);
Expand Down