gzip_disable msie6
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index 43d0ca9..c0c9e74 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -1672,6 +1672,10 @@
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
+ if (r->headers_in.msie6 && clcf->gzip_disable_msie6) {
+ return NGX_DECLINED;
+ }
+
if (r->http_version < clcf->gzip_http_version) {
return NGX_DECLINED;
}
@@ -2677,6 +2681,7 @@
lcf->gzip_http_version = NGX_CONF_UNSET_UINT;
#if (NGX_PCRE)
lcf->gzip_disable = NGX_CONF_UNSET_PTR;
+ lcf->gzip_disable_msie6 = 3;
#endif
#endif
@@ -2914,6 +2919,11 @@
ngx_conf_merge_ptr_value(conf->gzip_disable, prev->gzip_disable, NULL);
#endif
+ if (conf->gzip_disable_msie6 == 3) {
+ conf->gzip_disable_msie6 =
+ (prev->gzip_disable_msie6 == 3) ? 0 : prev->gzip_disable_msie6;
+ }
+
#endif
return NGX_CONF_OK;
@@ -3753,9 +3763,10 @@
static char *
ngx_http_gzip_disable(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
-#if (NGX_PCRE)
ngx_http_core_loc_conf_t *clcf = conf;
+#if (NGX_PCRE)
+
ngx_str_t err, *value;
ngx_uint_t i;
ngx_regex_elt_t *re;
@@ -3776,6 +3787,11 @@
for (i = 1; i < cf->args->nelts; i++) {
+ if (ngx_strcmp(value[1].data, "msie6") == 0) {
+ clcf->gzip_disable_msie6 = 1;
+ continue;
+ }
+
re = ngx_array_push(clcf->gzip_disable);
if (re == NULL) {
return NGX_CONF_ERROR;
@@ -3795,8 +3811,18 @@
return NGX_CONF_OK;
#else
+ ngx_str_t *value;
+
+ value = cf->args->elts;
+
+ if (cf->args->nelts == 2 && ngx_strcmp(value[1].data, "msie6") == 0) {
+ clcf->gzip_disable_msie6 = 1;
+ return NGX_CONF_OK;
+ }
+
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
- "\"gzip_disable\" requires PCRE library");
+ "without PCRE library \"gzip_disable\" supports "
+ "builtin \"msie6\" mask only");
return NGX_CONF_ERROR;
#endif
diff --git a/src/http/ngx_http_core_module.h b/src/http/ngx_http_core_module.h
index a42b0da..c1ae27d 100644
--- a/src/http/ngx_http_core_module.h
+++ b/src/http/ngx_http_core_module.h
@@ -242,6 +242,9 @@
unsigned auto_redirect:1;
unsigned alias:1;
+#if (NGX_HTTP_GZIP)
+ unsigned gzip_disable_msie6:2;
+#endif
ngx_http_location_tree_node_t *static_locations;
ngx_http_core_loc_conf_t **regex_locations;
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
index 6ae0be3..94f786e 100644
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -1290,7 +1290,7 @@
ngx_http_process_user_agent(ngx_http_request_t *r, ngx_table_elt_t *h,
ngx_uint_t offset)
{
- u_char *ua, *user_agent;
+ u_char *user_agent, *msie;
if (r->headers_in.user_agent) {
return NGX_OK;
@@ -1302,14 +1302,22 @@
user_agent = h->value.data;
- ua = ngx_strstrn(user_agent, "MSIE", 4 - 1);
+ msie = ngx_strstrn(user_agent, "MSIE ", 5 - 1);
- if (ua && ua + 8 < user_agent + h->value.len) {
+ if (msie && msie + 7 < user_agent + h->value.len) {
r->headers_in.msie = 1;
- if (ua[4] == ' ' && ua[5] == '4' && ua[6] == '.') {
- r->headers_in.msie4 = 1;
+ if (msie[6] == '.') {
+
+ switch (msie[5]) {
+ case '4':
+ r->headers_in.msie4 = 1;
+ /* fall through */
+ case '5':
+ case '6':
+ r->headers_in.msie6 = 1;
+ }
}
#if 0
@@ -1324,6 +1332,7 @@
r->headers_in.opera = 1;
r->headers_in.msie = 0;
r->headers_in.msie4 = 0;
+ r->headers_in.msie6 = 0;
}
if (!r->headers_in.msie && !r->headers_in.opera) {
diff --git a/src/http/ngx_http_request.h b/src/http/ngx_http_request.h
index 034da1c..6368398 100644
--- a/src/http/ngx_http_request.h
+++ b/src/http/ngx_http_request.h
@@ -214,6 +214,7 @@
unsigned connection_type:2;
unsigned msie:1;
unsigned msie4:1;
+ unsigned msie6:1;
unsigned opera:1;
unsigned gecko:1;
unsigned konqueror:1;