Mercurial > hg > nginx-vendor-0-7
comparison src/http/modules/ngx_http_gzip_filter_module.c @ 382:984bb0b1399b NGINX_0_7_3
nginx 0.7.3
*) Change: the "rss" extension MIME type has been changed to
"application/rss+xml".
*) Change: now the "gzip_vary" directive turned on issues a
"Vary: Accept-Encoding" header line for uncompressed responses too.
*) Feature: now the "rewrite" directive does a redirect automatically
if the "https://" protocol is used.
*) Bugfix: the "proxy_pass" directive did not work with the HTTPS
protocol; the bug had appeared in 0.6.9.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Mon, 23 Jun 2008 00:00:00 +0400 |
parents | 9121a0a91f47 |
children | 05981f639d21 |
comparison
equal
deleted
inserted
replaced
381:23d1555141d9 | 382:984bb0b1399b |
---|---|
202 | 202 |
203 | 203 |
204 static ngx_int_t | 204 static ngx_int_t |
205 ngx_http_gzip_header_filter(ngx_http_request_t *r) | 205 ngx_http_gzip_header_filter(ngx_http_request_t *r) |
206 { | 206 { |
207 ngx_str_t *type; | 207 ngx_str_t *type; |
208 ngx_uint_t i; | 208 ngx_uint_t i; |
209 ngx_table_elt_t *h; | 209 ngx_table_elt_t *h; |
210 ngx_http_gzip_ctx_t *ctx; | 210 ngx_http_gzip_ctx_t *ctx; |
211 ngx_http_gzip_conf_t *conf; | 211 ngx_http_gzip_conf_t *conf; |
212 ngx_http_core_loc_conf_t *clcf; | |
213 | 212 |
214 conf = ngx_http_get_module_loc_conf(r, ngx_http_gzip_filter_module); | 213 conf = ngx_http_get_module_loc_conf(r, ngx_http_gzip_filter_module); |
215 | 214 |
216 if (!conf->enable | 215 if (!conf->enable |
217 || (r->headers_out.status != NGX_HTTP_OK | 216 || (r->headers_out.status != NGX_HTTP_OK |
262 h->value.len = sizeof("gzip") - 1; | 261 h->value.len = sizeof("gzip") - 1; |
263 h->value.data = (u_char *) "gzip"; | 262 h->value.data = (u_char *) "gzip"; |
264 | 263 |
265 r->headers_out.content_encoding = h; | 264 r->headers_out.content_encoding = h; |
266 | 265 |
267 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); | |
268 | |
269 if (clcf->gzip_vary) { | |
270 h = ngx_list_push(&r->headers_out.headers); | |
271 if (h == NULL) { | |
272 return NGX_ERROR; | |
273 } | |
274 | |
275 h->hash = 1; | |
276 h->key.len = sizeof("Vary") - 1; | |
277 h->key.data = (u_char *) "Vary"; | |
278 h->value.len = sizeof("Accept-Encoding") - 1; | |
279 h->value.data = (u_char *) "Accept-Encoding"; | |
280 } | |
281 | |
282 ctx->length = r->headers_out.content_length_n; | 266 ctx->length = r->headers_out.content_length_n; |
283 | 267 |
284 r->main_filter_need_in_memory = 1; | 268 r->main_filter_need_in_memory = 1; |
285 | 269 |
286 ngx_http_clear_content_length(r); | 270 ngx_http_clear_content_length(r); |
800 if (ctx == NULL || ctx->zout == 0) { | 784 if (ctx == NULL || ctx->zout == 0) { |
801 v->not_found = 1; | 785 v->not_found = 1; |
802 return NGX_OK; | 786 return NGX_OK; |
803 } | 787 } |
804 | 788 |
805 v->data = ngx_palloc(r->pool, NGX_INT32_LEN + 3); | 789 v->data = ngx_pnalloc(r->pool, NGX_INT32_LEN + 3); |
806 if (v->data == NULL) { | 790 if (v->data == NULL) { |
807 return NGX_ERROR; | 791 return NGX_ERROR; |
808 } | 792 } |
809 | 793 |
810 zint = (ngx_uint_t) (ctx->zin / ctx->zout); | 794 zint = (ngx_uint_t) (ctx->zin / ctx->zout); |
949 return NGX_CONF_ERROR; | 933 return NGX_CONF_ERROR; |
950 } | 934 } |
951 | 935 |
952 type->len = value[i].len; | 936 type->len = value[i].len; |
953 | 937 |
954 type->data = ngx_palloc(cf->pool, type->len + 1); | 938 type->data = ngx_pnalloc(cf->pool, type->len + 1); |
955 if (type->data == NULL) { | 939 if (type->data == NULL) { |
956 return NGX_CONF_ERROR; | 940 return NGX_CONF_ERROR; |
957 } | 941 } |
958 | 942 |
959 ngx_cpystrn(type->data, value[i].data, type->len + 1); | 943 ngx_cpystrn(type->data, value[i].data, type->len + 1); |