Репозиторий ALT Linux backports/2.4
Последнее обновление: 9 июля 2008 | Пакетов: 497 | Посещений: 1488762
 поиск   регистрация   авторизация 
 
Группа :: Система/Серверы
Пакет: nginx

 Главная   Изменения   Спек   Патчи   Загрузить   Bugs and FR 

Патч: nginx-0.3.53-gzip_vary.patch


diff -uNpr nginx-0.3.53.orig/src/http/modules/ngx_http_gzip_filter_module.c nginx-0.3.53/src/http/modules/ngx_http_gzip_filter_module.c
--- nginx-0.3.53.orig/src/http/modules/ngx_http_gzip_filter_module.c	2006-07-07 00:50:33 +0400
+++ nginx-0.3.53/src/http/modules/ngx_http_gzip_filter_module.c	2006-07-12 02:24:40 +0400
@@ -14,6 +14,7 @@
 typedef struct {
     ngx_flag_t           enable;
     ngx_flag_t           no_buffer;
+    ngx_flag_t		 vary;
 
     ngx_array_t         *types;     /* array of ngx_str_t */
 
@@ -132,6 +133,14 @@ static ngx_command_t  ngx_http_gzip_filt
       offsetof(ngx_http_gzip_conf_t, enable),
       NULL },
 
+    { ngx_string("gzip_vary"),
+      NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
+                        |NGX_CONF_FLAG,
+      ngx_conf_set_flag_slot,
+      NGX_HTTP_LOC_CONF_OFFSET,
+      offsetof(ngx_http_gzip_conf_t, vary),
+      NULL },
+    
     { ngx_string("gzip_buffers"),
       NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE2,
       ngx_conf_set_bufs_slot,
@@ -350,14 +359,30 @@ found:
         return NGX_ERROR;
     }
 
+    if (conf->vary) {
+	r->headers_out.accept_encoding = ngx_list_push(&r->headers_out.headers);
+	if (r->headers_out.accept_encoding == NULL) {
+	    return NGX_ERROR;
+	}
+    }
+    
     r->headers_out.content_encoding->hash = 1;
     r->headers_out.content_encoding->key.len = sizeof("Content-Encoding") - 1;
     r->headers_out.content_encoding->key.data = (u_char *) "Content-Encoding";
     r->headers_out.content_encoding->value.len = sizeof("gzip") - 1;
     r->headers_out.content_encoding->value.data = (u_char *) "gzip";
-
+    if (conf->vary) {
+	r->headers_out.accept_encoding->hash = 1;
+	r->headers_out.accept_encoding->key.len = sizeof("Accept-Encoding") - 1;
+	r->headers_out.accept_encoding->key.data = (u_char *) "Accept-Encoding";
+	r->headers_out.accept_encoding->value.len = sizeof("Vary") - 1;
+	r->headers_out.accept_encoding->value.data = (u_char *) "Vary";
+    }
+    
     ctx->length = r->headers_out.content_length_n;
 
+    
+    
     r->main_filter_need_in_memory = 1;
 
     ngx_http_clear_content_length(r);
@@ -1062,6 +1087,7 @@ ngx_http_gzip_create_conf(ngx_conf_t *cf
      */
 
     conf->enable = NGX_CONF_UNSET;
+    conf->vary = NGX_CONF_UNSET;
     conf->no_buffer = NGX_CONF_UNSET;
 
     conf->http_version = NGX_CONF_UNSET_UINT;
@@ -1085,6 +1111,8 @@ ngx_http_gzip_merge_conf(ngx_conf_t *cf,
 
     ngx_conf_merge_value(conf->enable, prev->enable, 0);
 
+    ngx_conf_merge_value(conf->vary, prev->vary, 0);
+
     ngx_conf_merge_bufs_value(conf->bufs, prev->bufs, 4, ngx_pagesize);
 
     ngx_conf_merge_uint_value(conf->http_version, prev->http_version,
diff -uNpr nginx-0.3.53.orig/src/http/ngx_http_header_filter_module.c nginx-0.3.53/src/http/ngx_http_header_filter_module.c
--- nginx-0.3.53.orig/src/http/ngx_http_header_filter_module.c	2006-07-04 14:40:15 +0400
+++ nginx-0.3.53/src/http/ngx_http_header_filter_module.c	2006-07-12 02:24:40 +0400
@@ -133,6 +133,8 @@ ngx_http_header_out_t  ngx_http_headers_
                  offsetof(ngx_http_headers_out_t, content_length) },
     { ngx_string("Content-Encoding"),
                  offsetof(ngx_http_headers_out_t, content_encoding) },
+    { ngx_string("Accept-Encoding"),
+                 offsetof(ngx_http_headers_out_t, accept_encoding) },
     { ngx_string("Location"), offsetof(ngx_http_headers_out_t, location) },
     { ngx_string("Last-Modified"),
                  offsetof(ngx_http_headers_out_t, last_modified) },
diff -uNpr nginx-0.3.53.orig/src/http/ngx_http_request.h nginx-0.3.53/src/http/ngx_http_request.h
--- nginx-0.3.53.orig/src/http/ngx_http_request.h	2006-07-07 17:27:40 +0400
+++ nginx-0.3.53/src/http/ngx_http_request.h	2006-07-12 02:25:08 +0400
@@ -229,6 +229,10 @@ typedef struct {
     ngx_table_elt_t                  *expires;
     ngx_table_elt_t                  *etag;
 
+#if (NGX_HTTP_GZIP)
+    ngx_table_elt_t		     *accept_encoding;
+#endif
+
     ngx_str_t                        *override_charset;
 
     size_t                            content_type_len;
 
design & coding: Vladimir Lettiev aka crux © 2004-2005