Hi, This is ultimately a pretty simply change. When an proxied resource has been sdch encoded, currently the gzip module refuses to run. This change causes gzip to run on sdch resources and ensures that gzip is appended to the Content-Encoding header, keeping the sdch flag.
For a working sdch server implementation, see <https://github.com/baranov1ch/connect-sdch>. Regards, Tom Thorogood.
# HG changeset patch # User Tom Thorogood <m...@tomthorogood.co.uk> # Date 1430387824 -34200 # Thu Apr 30 19:27:04 2015 +0930 # Node ID 6362d16853e4be2d86ee3f0047ba7c52457cd064 # Parent 162b2d27d4e1ce45bb9217d6958348c64f726a28 HTTP: gzip resources upstream has flagged as sdch encoded. This prevents gzip_filter_module from skipping when the resource has 'Content-Encoding: sdch' set. According to the spec, when encountering sdch (Shared Dictionary Compression over HTTP) encoded responses: 'The server may apply multiple Content-Encodings to the response, (e.g. sdch and gzip) in which case subsequent encoding tokens are appended to the Content-Encoding header, per the HTTP/1.1 RFC section 14.11.'. - A Proposal for Shared Dictionary Compression over HTTP This change does not allow nginx to sdch encode a resource, it merely allows gzip to encode already sdch encoded responses. diff -r 162b2d27d4e1 -r 6362d16853e4 src/http/modules/ngx_http_gzip_filter_module.c --- a/src/http/modules/ngx_http_gzip_filter_module.c Wed Apr 29 14:59:02 2015 +0300 +++ b/src/http/modules/ngx_http_gzip_filter_module.c Thu Apr 30 19:27:04 2015 +0930 @@ -248,7 +248,10 @@ && r->headers_out.status != NGX_HTTP_FORBIDDEN && r->headers_out.status != NGX_HTTP_NOT_FOUND) || (r->headers_out.content_encoding - && r->headers_out.content_encoding->value.len) + && r->headers_out.content_encoding->value.len + && (r->headers_out.content_encoding->value.len != 4 + || ngx_strncmp(r->headers_out.content_encoding->value.data, + "sdch", 4) != 0)) || (r->headers_out.content_length_n != -1 && r->headers_out.content_length_n < conf->min_length) || ngx_http_test_content_type(r, &conf->types) == NULL @@ -299,7 +302,18 @@ h->hash = 1; ngx_str_set(&h->key, "Content-Encoding"); - ngx_str_set(&h->value, "gzip"); + + if (r->headers_out.content_encoding + && r->headers_out.content_encoding->value.len == 4 + && ngx_strncmp(r->headers_out.content_encoding->value.data, + "sdch", 4) == 0) { + r->headers_out.content_encoding->hash = 0; + + ngx_str_set(&h->value, "sdch, gzip"); + } else { + ngx_str_set(&h->value, "gzip"); + } + r->headers_out.content_encoding = h; r->main_filter_need_in_memory = 1;
_______________________________________________ nginx-devel mailing list nginx-devel@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx-devel