mirror of
https://github.com/nginx/nginx.git
synced 2025-06-08 02:02:38 +08:00
Accept-Encoding refactoring: test first the most common case "gzip,"
This commit is contained in:
parent
6652cc5962
commit
d743a2339e
@ -2013,23 +2013,43 @@ ngx_http_auth_basic_user(ngx_http_request_t *r)
|
|||||||
ngx_int_t
|
ngx_int_t
|
||||||
ngx_http_gzip_ok(ngx_http_request_t *r)
|
ngx_http_gzip_ok(ngx_http_request_t *r)
|
||||||
{
|
{
|
||||||
|
u_char *g;
|
||||||
time_t date, expires;
|
time_t date, expires;
|
||||||
ngx_uint_t p;
|
ngx_uint_t p;
|
||||||
ngx_array_t *cc;
|
ngx_array_t *cc;
|
||||||
ngx_table_elt_t *e, *d;
|
ngx_table_elt_t *e, *d, *ae;
|
||||||
ngx_http_core_loc_conf_t *clcf;
|
ngx_http_core_loc_conf_t *clcf;
|
||||||
|
|
||||||
r->gzip_tested = 1;
|
r->gzip_tested = 1;
|
||||||
|
|
||||||
if (r != r->main
|
if (r != r->main) {
|
||||||
|| r->headers_in.accept_encoding == NULL
|
|
||||||
|| ngx_strcasestrn(r->headers_in.accept_encoding->value.data,
|
|
||||||
"gzip", 4 - 1)
|
|
||||||
== NULL)
|
|
||||||
{
|
|
||||||
return NGX_DECLINED;
|
return NGX_DECLINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ae = r->headers_in.accept_encoding;
|
||||||
|
if (ae == NULL) {
|
||||||
|
return NGX_DECLINED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ngx_strncmp(ae->value.data, "gzip,", 5) == 0) {
|
||||||
|
/*
|
||||||
|
* test for the most common case "gzip,...":
|
||||||
|
* MSIE: "gzip, deflate"
|
||||||
|
* Firefox: "gzip,deflate"
|
||||||
|
* Chrome: "gzip,deflate,sdch"
|
||||||
|
* Safari: "gzip, deflate"
|
||||||
|
* Opera: "gzip, deflate"
|
||||||
|
*/
|
||||||
|
goto found;
|
||||||
|
}
|
||||||
|
|
||||||
|
g = ngx_strcasestrn(ae->value.data, "gzip", 4 - 1);
|
||||||
|
if (g == NULL) {
|
||||||
|
return NGX_DECLINED;
|
||||||
|
}
|
||||||
|
|
||||||
|
found:
|
||||||
|
|
||||||
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
|
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
|
||||||
|
|
||||||
if (r->headers_in.msie6 && clcf->gzip_disable_msie6) {
|
if (r->headers_in.msie6 && clcf->gzip_disable_msie6) {
|
||||||
|
Loading…
Reference in New Issue
Block a user