Mercurial > hg > nginx
comparison src/http/ngx_http_core_module.c @ 3979:1d9353fbc077
Accept-Encoding refactoring: test first the most common case "gzip,"
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Sat, 30 Jul 2011 07:34:12 +0000 |
parents | 6b608bf9f3ae |
children | 19de03b4217f |
comparison
equal
deleted
inserted
replaced
3978:6b608bf9f3ae | 3979:1d9353fbc077 |
---|---|
2011 #if (NGX_HTTP_GZIP) | 2011 #if (NGX_HTTP_GZIP) |
2012 | 2012 |
2013 ngx_int_t | 2013 ngx_int_t |
2014 ngx_http_gzip_ok(ngx_http_request_t *r) | 2014 ngx_http_gzip_ok(ngx_http_request_t *r) |
2015 { | 2015 { |
2016 u_char *g; | |
2016 time_t date, expires; | 2017 time_t date, expires; |
2017 ngx_uint_t p; | 2018 ngx_uint_t p; |
2018 ngx_array_t *cc; | 2019 ngx_array_t *cc; |
2019 ngx_table_elt_t *e, *d; | 2020 ngx_table_elt_t *e, *d, *ae; |
2020 ngx_http_core_loc_conf_t *clcf; | 2021 ngx_http_core_loc_conf_t *clcf; |
2021 | 2022 |
2022 r->gzip_tested = 1; | 2023 r->gzip_tested = 1; |
2023 | 2024 |
2024 if (r != r->main | 2025 if (r != r->main) { |
2025 || r->headers_in.accept_encoding == NULL | |
2026 || ngx_strcasestrn(r->headers_in.accept_encoding->value.data, | |
2027 "gzip", 4 - 1) | |
2028 == NULL) | |
2029 { | |
2030 return NGX_DECLINED; | 2026 return NGX_DECLINED; |
2031 } | 2027 } |
2028 | |
2029 ae = r->headers_in.accept_encoding; | |
2030 if (ae == NULL) { | |
2031 return NGX_DECLINED; | |
2032 } | |
2033 | |
2034 if (ngx_strncmp(ae->value.data, "gzip,", 5) == 0) { | |
2035 /* | |
2036 * test for the most common case "gzip,...": | |
2037 * MSIE: "gzip, deflate" | |
2038 * Firefox: "gzip,deflate" | |
2039 * Chrome: "gzip,deflate,sdch" | |
2040 * Safari: "gzip, deflate" | |
2041 * Opera: "gzip, deflate" | |
2042 */ | |
2043 goto found; | |
2044 } | |
2045 | |
2046 g = ngx_strcasestrn(ae->value.data, "gzip", 4 - 1); | |
2047 if (g == NULL) { | |
2048 return NGX_DECLINED; | |
2049 } | |
2050 | |
2051 found: | |
2032 | 2052 |
2033 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); | 2053 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); |
2034 | 2054 |
2035 if (r->headers_in.msie6 && clcf->gzip_disable_msie6) { | 2055 if (r->headers_in.msie6 && clcf->gzip_disable_msie6) { |
2036 return NGX_DECLINED; | 2056 return NGX_DECLINED; |