comparison src/http/modules/ngx_http_gzip_filter_module.c @ 328:26ff8d6b618d NGINX_0_5_34

nginx 0.5.34 *) Change: now the full request line instead of URI only is written to error_log. *) Feature: Cygwin compatibility. Thanks to Vladimir Kutakov. *) Feature: the "merge_slashes" directive. *) Feature: the "gzip_vary" directive. *) Feature: the "server_tokens" directive. *) Feature: the "access_log" directive may be used inside the "limit_except" block. *) Bugfix: if the $server_protocol was used in FastCGI parameters and a request line length was near to the "client_header_buffer_size" directive value, then nginx issued an alert "fastcgi: the request record is too big". *) Bugfix: if a plain text HTTP/0.9 version request was made to HTTPS server, then nginx returned usual response. *) Bugfix: URL double escaping in a redirect of the "msie_refresh" directive; bug appeared in 0.5.28. *) Bugfix: a segmentation fault might occur in worker process if subrequests were used. *) Bugfix: the big responses may be transferred truncated if SSL and gzip were used. *) Bugfix: compatibility with mget. *) Bugfix: nginx did not unescape URI in the "include" SSI command. *) Bugfix: the segmentation fault was occurred on start or while reconfiguration if variable was used in the "charset" or "source_charset" directives. *) Bugfix: nginx returned the 400 response on requests like "GET http://www.domain.com HTTP/1.0". Thanks to James Oakley. *) Bugfix: a segmentation fault occurred in worker process if $date_local and $date_gmt were used outside the ngx_http_ssi_filter_module. *) Bugfix: a segmentation fault might occur in worker process if debug log was enabled. Thanks to Andrei Nigmatulin. *) Bugfix: ngx_http_memcached_module did not set $upstream_response_time. Thanks to Maxim Dounin. *) Bugfix: a worker process may got caught in an endless loop, if the memcached was used.
author Igor Sysoev <http://sysoev.ru>
date Thu, 13 Dec 2007 00:00:00 +0300
parents f70f2f565fe0
children
comparison
equal deleted inserted replaced
327:cb962a94cd7b 328:26ff8d6b618d
12 12
13 13
14 typedef struct { 14 typedef struct {
15 ngx_flag_t enable; 15 ngx_flag_t enable;
16 ngx_flag_t no_buffer; 16 ngx_flag_t no_buffer;
17 ngx_flag_t vary;
17 18
18 ngx_array_t *types; /* array of ngx_str_t */ 19 ngx_array_t *types; /* array of ngx_str_t */
19 20
20 ngx_bufs_t bufs; 21 ngx_bufs_t bufs;
21 22
188 { ngx_string("gzip_min_length"), 189 { ngx_string("gzip_min_length"),
189 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, 190 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
190 ngx_conf_set_size_slot, 191 ngx_conf_set_size_slot,
191 NGX_HTTP_LOC_CONF_OFFSET, 192 NGX_HTTP_LOC_CONF_OFFSET,
192 offsetof(ngx_http_gzip_conf_t, min_length), 193 offsetof(ngx_http_gzip_conf_t, min_length),
194 NULL },
195
196 { ngx_string("gzip_vary"),
197 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
198 ngx_conf_set_flag_slot,
199 NGX_HTTP_LOC_CONF_OFFSET,
200 offsetof(ngx_http_gzip_conf_t, vary),
193 NULL }, 201 NULL },
194 202
195 ngx_null_command 203 ngx_null_command
196 }; 204 };
197 205
259 static ngx_int_t 267 static ngx_int_t
260 ngx_http_gzip_header_filter(ngx_http_request_t *r) 268 ngx_http_gzip_header_filter(ngx_http_request_t *r)
261 { 269 {
262 ngx_str_t *type; 270 ngx_str_t *type;
263 ngx_uint_t i; 271 ngx_uint_t i;
272 ngx_table_elt_t *header;
264 ngx_http_gzip_ctx_t *ctx; 273 ngx_http_gzip_ctx_t *ctx;
265 ngx_http_gzip_conf_t *conf; 274 ngx_http_gzip_conf_t *conf;
266 275
267 conf = ngx_http_get_module_loc_conf(r, ngx_http_gzip_filter_module); 276 conf = ngx_http_get_module_loc_conf(r, ngx_http_gzip_filter_module);
268 277
334 ngx_http_set_ctx(r, ctx, ngx_http_gzip_filter_module); 343 ngx_http_set_ctx(r, ctx, ngx_http_gzip_filter_module);
335 344
336 345
337 ctx->request = r; 346 ctx->request = r;
338 347
339 r->headers_out.content_encoding = ngx_list_push(&r->headers_out.headers); 348 header = ngx_list_push(&r->headers_out.headers);
340 if (r->headers_out.content_encoding == NULL) { 349 if (header == NULL) {
341 return NGX_ERROR; 350 return NGX_ERROR;
342 } 351 }
343 352
344 r->headers_out.content_encoding->hash = 1; 353 header->hash = 1;
345 r->headers_out.content_encoding->key.len = sizeof("Content-Encoding") - 1; 354 header->key.len = sizeof("Content-Encoding") - 1;
346 r->headers_out.content_encoding->key.data = (u_char *) "Content-Encoding"; 355 header->key.data = (u_char *) "Content-Encoding";
347 r->headers_out.content_encoding->value.len = sizeof("gzip") - 1; 356 header->value.len = sizeof("gzip") - 1;
348 r->headers_out.content_encoding->value.data = (u_char *) "gzip"; 357 header->value.data = (u_char *) "gzip";
358
359 r->headers_out.content_encoding = header;
360
361 if (conf->vary) {
362 header = ngx_list_push(&r->headers_out.headers);
363 if (header == NULL) {
364 return NGX_ERROR;
365 }
366
367 header->hash = 1;
368 header->key.len = sizeof("Vary") - 1;
369 header->key.data = (u_char *) "Vary";
370 header->value.len = sizeof("Accept-Encoding") - 1;
371 header->value.data = (u_char *) "Accept-Encoding";
372 }
349 373
350 ctx->length = r->headers_out.content_length_n; 374 ctx->length = r->headers_out.content_length_n;
351 375
352 r->main_filter_need_in_memory = 1; 376 r->main_filter_need_in_memory = 1;
353 377
811 835
812 break; 836 break;
813 } 837 }
814 } 838 }
815 839
816 if (last == NGX_AGAIN && !ctx->done) { 840 if (ctx->out == NULL) {
817 return NGX_AGAIN; 841
818 } 842 if (last == NGX_AGAIN) {
819 843 return NGX_AGAIN;
820 if (ctx->out == NULL && ctx->busy == NULL) { 844 }
821 return NGX_OK; 845
846 if (ctx->busy == NULL) {
847 return NGX_OK;
848 }
822 } 849 }
823 850
824 last = ngx_http_next_body_filter(r, ctx->out); 851 last = ngx_http_next_body_filter(r, ctx->out);
825 852
826 /* 853 /*
938 { 965 {
939 ngx_uint_t zint, zfrac; 966 ngx_uint_t zint, zfrac;
940 ngx_http_gzip_ctx_t *ctx; 967 ngx_http_gzip_ctx_t *ctx;
941 968
942 v->valid = 1; 969 v->valid = 1;
943 v->no_cachable = 0; 970 v->no_cacheable = 0;
944 v->not_found = 0; 971 v->not_found = 0;
945 972
946 ctx = ngx_http_get_module_ctx(r, ngx_http_gzip_filter_module); 973 ctx = ngx_http_get_module_ctx(r, ngx_http_gzip_filter_module);
947 974
948 if (ctx == NULL || ctx->zout == 0) { 975 if (ctx == NULL || ctx->zout == 0) {
994 * conf->types = NULL; 1021 * conf->types = NULL;
995 */ 1022 */
996 1023
997 conf->enable = NGX_CONF_UNSET; 1024 conf->enable = NGX_CONF_UNSET;
998 conf->no_buffer = NGX_CONF_UNSET; 1025 conf->no_buffer = NGX_CONF_UNSET;
1026 conf->vary = NGX_CONF_UNSET;
999 1027
1000 conf->http_version = NGX_CONF_UNSET_UINT; 1028 conf->http_version = NGX_CONF_UNSET_UINT;
1001 1029
1002 conf->level = NGX_CONF_UNSET; 1030 conf->level = NGX_CONF_UNSET;
1003 conf->wbits = (size_t) NGX_CONF_UNSET; 1031 conf->wbits = (size_t) NGX_CONF_UNSET;
1029 ngx_conf_merge_size_value(conf->wbits, prev->wbits, MAX_WBITS); 1057 ngx_conf_merge_size_value(conf->wbits, prev->wbits, MAX_WBITS);
1030 ngx_conf_merge_size_value(conf->memlevel, prev->memlevel, 1058 ngx_conf_merge_size_value(conf->memlevel, prev->memlevel,
1031 MAX_MEM_LEVEL - 1); 1059 MAX_MEM_LEVEL - 1);
1032 ngx_conf_merge_value(conf->min_length, prev->min_length, 20); 1060 ngx_conf_merge_value(conf->min_length, prev->min_length, 20);
1033 ngx_conf_merge_value(conf->no_buffer, prev->no_buffer, 0); 1061 ngx_conf_merge_value(conf->no_buffer, prev->no_buffer, 0);
1062 ngx_conf_merge_value(conf->vary, prev->vary, 0);
1034 1063
1035 if (conf->types == NULL) { 1064 if (conf->types == NULL) {
1036 if (prev->types == NULL) { 1065 if (prev->types == NULL) {
1037 conf->types = ngx_array_create(cf->pool, 1, sizeof(ngx_str_t)); 1066 conf->types = ngx_array_create(cf->pool, 1, sizeof(ngx_str_t));
1038 if (conf->types == NULL) { 1067 if (conf->types == NULL) {