annotate src/http/modules/ngx_http_gzip_static_module.c @ 4248:2fad4d19ea4b stable-1.0

Merging r4151, r4152, r4177: HTTP cache related fixes: *) Cache: fix for sending of empty responses. Revert wrong fix for empty responses introduced in 0.8.31 and apply new one, rewritten to match things done by static module as close as possible. *) Cache: fix for sending of stale responses. For normal cached responses ngx_http_cache_send() sends last buffer and then request finalized via ngx_http_finalize_request() call, i.e. everything is ok. But for stale responses (i.e. when upstream died, but we have something in cache) the same ngx_http_cache_send() sends last buffer, but then in ngx_http_upstream_finalize_request() another last buffer is send. This causes duplicate final chunk to appear if chunked encoding is used (and resulting problems with keepalive connections and so on). Fix this by not sending in ngx_http_upstream_finalize_request() another last buffer if we know response was from cache. *) Fixed cache bypass caching of non-cacheable replies (ticket #21). If cache was bypassed with proxy_cache_bypass, cache-controlling headers (Cache-Control, Expires) wasn't considered and response was cached even if it was actually non-cacheable. Patch by John Ferlito.
author Igor Sysoev <igor@sysoev.ru>
date Tue, 01 Nov 2011 13:49:31 +0000
parents 84905c7b2aa7
children d620f497c50f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
441
da8c5707af39 nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents: 416
diff changeset
1
da8c5707af39 nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents: 416
diff changeset
2 /*
444
42d11f017717 nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents: 441
diff changeset
3 * Copyright (C) Igor Sysoev
441
da8c5707af39 nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents: 416
diff changeset
4 */
da8c5707af39 nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents: 416
diff changeset
5
1
d220029ac7f3 nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
6
d220029ac7f3 nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
7 #include <ngx_config.h>
87
5f6d848dcbef nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 74
diff changeset
8 #include <ngx_core.h>
3
34a521b1a148 nginx-0.0.1-2002-08-20-18:48:28 import
Igor Sysoev <igor@sysoev.ru>
parents: 1
diff changeset
9 #include <ngx_http.h>
34a521b1a148 nginx-0.0.1-2002-08-20-18:48:28 import
Igor Sysoev <igor@sysoev.ru>
parents: 1
diff changeset
10
1
d220029ac7f3 nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
11
1790
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
12 typedef struct {
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
13 ngx_flag_t enable;
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
14 } ngx_http_gzip_static_conf_t;
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
15
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
16
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
17 static ngx_int_t ngx_http_gzip_static_handler(ngx_http_request_t *r);
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
18 static void *ngx_http_gzip_static_create_conf(ngx_conf_t *cf);
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
19 static char *ngx_http_gzip_static_merge_conf(ngx_conf_t *cf, void *parent,
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
20 void *child);
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
21 static ngx_int_t ngx_http_gzip_static_init(ngx_conf_t *cf);
148
5afee0074707 nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 143
diff changeset
22
5afee0074707 nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 143
diff changeset
23
1790
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
24 static ngx_command_t ngx_http_gzip_static_commands[] = {
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
25
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
26 { ngx_string("gzip_static"),
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
27 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
28 ngx_conf_set_flag_slot,
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
29 NGX_HTTP_LOC_CONF_OFFSET,
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
30 offsetof(ngx_http_gzip_static_conf_t, enable),
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
31 NULL },
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
32
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
33 ngx_null_command
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
34 };
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
35
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
36
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
37 ngx_http_module_t ngx_http_gzip_static_module_ctx = {
509
9b8c906f6e63 nginx-0.1.29-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 501
diff changeset
38 NULL, /* preconfiguration */
1790
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
39 ngx_http_gzip_static_init, /* postconfiguration */
177
4db54fdbcbe7 nginx-0.0.1-2003-11-10-20:17:31 import
Igor Sysoev <igor@sysoev.ru>
parents: 176
diff changeset
40
148
5afee0074707 nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 143
diff changeset
41 NULL, /* create main configuration */
5afee0074707 nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 143
diff changeset
42 NULL, /* init main configuration */
577
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 573
diff changeset
43
148
5afee0074707 nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 143
diff changeset
44 NULL, /* create server configuration */
5afee0074707 nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 143
diff changeset
45 NULL, /* merge server configuration */
577
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 573
diff changeset
46
1790
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
47 ngx_http_gzip_static_create_conf, /* create location configuration */
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
48 ngx_http_gzip_static_merge_conf /* merge location configuration */
577
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 573
diff changeset
49 };
148
5afee0074707 nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 143
diff changeset
50
5afee0074707 nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 143
diff changeset
51
1790
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
52 ngx_module_t ngx_http_gzip_static_module = {
509
9b8c906f6e63 nginx-0.1.29-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 501
diff changeset
53 NGX_MODULE_V1,
1790
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
54 &ngx_http_gzip_static_module_ctx, /* module context */
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
55 ngx_http_gzip_static_commands, /* module directives */
148
5afee0074707 nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 143
diff changeset
56 NGX_HTTP_MODULE, /* module type */
541
b09ee85d0ac8 nginx-0.1.45-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 527
diff changeset
57 NULL, /* init master */
681
7e24168b0853 nginx-0.4.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 645
diff changeset
58 NULL, /* init module */
541
b09ee85d0ac8 nginx-0.1.45-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 527
diff changeset
59 NULL, /* init process */
b09ee85d0ac8 nginx-0.1.45-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 527
diff changeset
60 NULL, /* init thread */
b09ee85d0ac8 nginx-0.1.45-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 527
diff changeset
61 NULL, /* exit thread */
b09ee85d0ac8 nginx-0.1.45-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 527
diff changeset
62 NULL, /* exit process */
b09ee85d0ac8 nginx-0.1.45-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 527
diff changeset
63 NULL, /* exit master */
b09ee85d0ac8 nginx-0.1.45-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 527
diff changeset
64 NGX_MODULE_V1_PADDING
148
5afee0074707 nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 143
diff changeset
65 };
5afee0074707 nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 143
diff changeset
66
5afee0074707 nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 143
diff changeset
67
509
9b8c906f6e63 nginx-0.1.29-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 501
diff changeset
68 static ngx_int_t
1790
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
69 ngx_http_gzip_static_handler(ngx_http_request_t *r)
148
5afee0074707 nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 143
diff changeset
70 {
1790
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
71 u_char *p;
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
72 size_t root;
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
73 ngx_str_t path;
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
74 ngx_int_t rc;
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
75 ngx_uint_t level;
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
76 ngx_log_t *log;
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
77 ngx_buf_t *b;
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
78 ngx_chain_t out;
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
79 ngx_table_elt_t *h;
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
80 ngx_open_file_info_t of;
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
81 ngx_http_core_loc_conf_t *clcf;
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
82 ngx_http_gzip_static_conf_t *gzcf;
201
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents: 200
diff changeset
83
645
4946078f0a79 nginx-0.3.44-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 639
diff changeset
84 if (!(r->method & (NGX_HTTP_GET|NGX_HTTP_HEAD))) {
1832
2547ef00c722 ngx_http_gzip_static_module should DECLINE request
Igor Sysoev <igor@sysoev.ru>
parents: 1799
diff changeset
85 return NGX_DECLINED;
639
715d24327080 nginx-0.3.41-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 603
diff changeset
86 }
715d24327080 nginx-0.3.41-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 603
diff changeset
87
201
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents: 200
diff changeset
88 if (r->uri.data[r->uri.len - 1] == '/') {
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents: 200
diff changeset
89 return NGX_DECLINED;
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents: 200
diff changeset
90 }
148
5afee0074707 nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 143
diff changeset
91
1790
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
92 gzcf = ngx_http_get_module_loc_conf(r, ngx_http_gzip_static_module);
201
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents: 200
diff changeset
93
3135
784126370092 nginx always sent "Vary: Accept-Encoding",
Igor Sysoev <igor@sysoev.ru>
parents: 2912
diff changeset
94 if (!gzcf->enable) {
784126370092 nginx always sent "Vary: Accept-Encoding",
Igor Sysoev <igor@sysoev.ru>
parents: 2912
diff changeset
95 return NGX_DECLINED;
784126370092 nginx always sent "Vary: Accept-Encoding",
Igor Sysoev <igor@sysoev.ru>
parents: 2912
diff changeset
96 }
784126370092 nginx always sent "Vary: Accept-Encoding",
Igor Sysoev <igor@sysoev.ru>
parents: 2912
diff changeset
97
3312
dddca6f42e7b nginx sent gzipped responses to clients those do not support gzip,
Igor Sysoev <igor@sysoev.ru>
parents: 3178
diff changeset
98 rc = ngx_http_gzip_ok(r);
dddca6f42e7b nginx sent gzipped responses to clients those do not support gzip,
Igor Sysoev <igor@sysoev.ru>
parents: 3178
diff changeset
99
3135
784126370092 nginx always sent "Vary: Accept-Encoding",
Igor Sysoev <igor@sysoev.ru>
parents: 2912
diff changeset
100 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
784126370092 nginx always sent "Vary: Accept-Encoding",
Igor Sysoev <igor@sysoev.ru>
parents: 2912
diff changeset
101
3312
dddca6f42e7b nginx sent gzipped responses to clients those do not support gzip,
Igor Sysoev <igor@sysoev.ru>
parents: 3178
diff changeset
102 if (!clcf->gzip_vary && rc != NGX_OK) {
1790
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
103 return NGX_DECLINED;
201
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents: 200
diff changeset
104 }
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents: 200
diff changeset
105
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents: 200
diff changeset
106 log = r->connection->log;
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents: 200
diff changeset
107
1790
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
108 p = ngx_http_map_uri_to_path(r, &path, &root, sizeof(".gz") - 1);
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
109 if (p == NULL) {
557
ecd9c160f25b nginx-0.3.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 553
diff changeset
110 return NGX_HTTP_INTERNAL_SERVER_ERROR;
400
69e851f83522 nginx-0.0.8-2004-07-26-20:21:18 import
Igor Sysoev <igor@sysoev.ru>
parents: 396
diff changeset
111 }
148
5afee0074707 nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 143
diff changeset
112
1790
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
113 *p++ = '.';
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
114 *p++ = 'g';
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
115 *p++ = 'z';
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
116 *p = '\0';
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
117
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
118 path.len = p - path.data;
1454
f497ed7682a7 open_file_cache in HTTP
Igor Sysoev <igor@sysoev.ru>
parents: 1374
diff changeset
119
201
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents: 200
diff changeset
120 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, log, 0,
557
ecd9c160f25b nginx-0.3.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 553
diff changeset
121 "http filename: \"%s\"", path.data);
148
5afee0074707 nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 143
diff changeset
122
2068
75a8d34459c5 ngx_memzero() ngx_open_file_info_t
Igor Sysoev <igor@sysoev.ru>
parents: 2063
diff changeset
123 ngx_memzero(&of, sizeof(ngx_open_file_info_t));
75a8d34459c5 ngx_memzero() ngx_open_file_info_t
Igor Sysoev <igor@sysoev.ru>
parents: 2063
diff changeset
124
3178
975f0558aab3 read_ahead
Igor Sysoev <igor@sysoev.ru>
parents: 3135
diff changeset
125 of.read_ahead = clcf->read_ahead;
2129
25add486e7aa directio
Igor Sysoev <igor@sysoev.ru>
parents: 2087
diff changeset
126 of.directio = clcf->directio;
1767
c42431762903 open_file_cache_retest > open_file_cache_valid
Igor Sysoev <igor@sysoev.ru>
parents: 1696
diff changeset
127 of.valid = clcf->open_file_cache_valid;
1772
25c93614e6b9 open_file_cache_min_uses
Igor Sysoev <igor@sysoev.ru>
parents: 1767
diff changeset
128 of.min_uses = clcf->open_file_cache_min_uses;
1454
f497ed7682a7 open_file_cache in HTTP
Igor Sysoev <igor@sysoev.ru>
parents: 1374
diff changeset
129 of.errors = clcf->open_file_cache_errors;
1457
223e92651ca5 open_file_cache_events
Igor Sysoev <igor@sysoev.ru>
parents: 1454
diff changeset
130 of.events = clcf->open_file_cache_events;
1454
f497ed7682a7 open_file_cache in HTTP
Igor Sysoev <igor@sysoev.ru>
parents: 1374
diff changeset
131
1799
0b5b94805d26 optimization
Igor Sysoev <igor@sysoev.ru>
parents: 1790
diff changeset
132 if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool)
0b5b94805d26 optimization
Igor Sysoev <igor@sysoev.ru>
parents: 1790
diff changeset
133 != NGX_OK)
0b5b94805d26 optimization
Igor Sysoev <igor@sysoev.ru>
parents: 1790
diff changeset
134 {
1454
f497ed7682a7 open_file_cache in HTTP
Igor Sysoev <igor@sysoev.ru>
parents: 1374
diff changeset
135 switch (of.err) {
f497ed7682a7 open_file_cache in HTTP
Igor Sysoev <igor@sysoev.ru>
parents: 1374
diff changeset
136
f497ed7682a7 open_file_cache in HTTP
Igor Sysoev <igor@sysoev.ru>
parents: 1374
diff changeset
137 case 0:
f497ed7682a7 open_file_cache in HTTP
Igor Sysoev <igor@sysoev.ru>
parents: 1374
diff changeset
138 return NGX_HTTP_INTERNAL_SERVER_ERROR;
148
5afee0074707 nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 143
diff changeset
139
1454
f497ed7682a7 open_file_cache in HTTP
Igor Sysoev <igor@sysoev.ru>
parents: 1374
diff changeset
140 case NGX_ENOENT:
f497ed7682a7 open_file_cache in HTTP
Igor Sysoev <igor@sysoev.ru>
parents: 1374
diff changeset
141 case NGX_ENOTDIR:
f497ed7682a7 open_file_cache in HTTP
Igor Sysoev <igor@sysoev.ru>
parents: 1374
diff changeset
142 case NGX_ENAMETOOLONG:
f497ed7682a7 open_file_cache in HTTP
Igor Sysoev <igor@sysoev.ru>
parents: 1374
diff changeset
143
1790
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
144 return NGX_DECLINED;
148
5afee0074707 nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 143
diff changeset
145
1454
f497ed7682a7 open_file_cache in HTTP
Igor Sysoev <igor@sysoev.ru>
parents: 1374
diff changeset
146 case NGX_EACCES:
f497ed7682a7 open_file_cache in HTTP
Igor Sysoev <igor@sysoev.ru>
parents: 1374
diff changeset
147
170
c42be4185301 nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents: 165
diff changeset
148 level = NGX_LOG_ERR;
1454
f497ed7682a7 open_file_cache in HTTP
Igor Sysoev <igor@sysoev.ru>
parents: 1374
diff changeset
149 break;
148
5afee0074707 nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 143
diff changeset
150
1454
f497ed7682a7 open_file_cache in HTTP
Igor Sysoev <igor@sysoev.ru>
parents: 1374
diff changeset
151 default:
f497ed7682a7 open_file_cache in HTTP
Igor Sysoev <igor@sysoev.ru>
parents: 1374
diff changeset
152
170
c42be4185301 nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents: 165
diff changeset
153 level = NGX_LOG_CRIT;
1454
f497ed7682a7 open_file_cache in HTTP
Igor Sysoev <igor@sysoev.ru>
parents: 1374
diff changeset
154 break;
148
5afee0074707 nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 143
diff changeset
155 }
170
c42be4185301 nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents: 165
diff changeset
156
1790
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
157 ngx_log_error(level, log, of.err,
2756
09cab3f8d92e *) of.test_only to not open file if only stat() is enough
Igor Sysoev <igor@sysoev.ru>
parents: 2721
diff changeset
158 "%s \"%s\" failed", of.failed, path.data);
170
c42be4185301 nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents: 165
diff changeset
159
1799
0b5b94805d26 optimization
Igor Sysoev <igor@sysoev.ru>
parents: 1790
diff changeset
160 return NGX_DECLINED;
148
5afee0074707 nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 143
diff changeset
161 }
5afee0074707 nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 143
diff changeset
162
3313
118169a8ec92 refactor gzip_vary handling
Igor Sysoev <igor@sysoev.ru>
parents: 3312
diff changeset
163 r->gzip_vary = 1;
118169a8ec92 refactor gzip_vary handling
Igor Sysoev <igor@sysoev.ru>
parents: 3312
diff changeset
164
3312
dddca6f42e7b nginx sent gzipped responses to clients those do not support gzip,
Igor Sysoev <igor@sysoev.ru>
parents: 3178
diff changeset
165 if (rc != NGX_OK) {
dddca6f42e7b nginx sent gzipped responses to clients those do not support gzip,
Igor Sysoev <igor@sysoev.ru>
parents: 3178
diff changeset
166 return NGX_DECLINED;
dddca6f42e7b nginx sent gzipped responses to clients those do not support gzip,
Igor Sysoev <igor@sysoev.ru>
parents: 3178
diff changeset
167 }
dddca6f42e7b nginx sent gzipped responses to clients those do not support gzip,
Igor Sysoev <igor@sysoev.ru>
parents: 3178
diff changeset
168
1696
f5f124fbfa3b delete useless variable
Igor Sysoev <igor@sysoev.ru>
parents: 1457
diff changeset
169 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, log, 0, "http static fd: %d", of.fd);
148
5afee0074707 nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 143
diff changeset
170
1454
f497ed7682a7 open_file_cache in HTTP
Igor Sysoev <igor@sysoev.ru>
parents: 1374
diff changeset
171 if (of.is_dir) {
201
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents: 200
diff changeset
172 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, log, 0, "http dir");
1790
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
173 return NGX_DECLINED;
148
5afee0074707 nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 143
diff changeset
174 }
5afee0074707 nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 143
diff changeset
175
461
a88a3e4e158f nginx-0.1.5-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 444
diff changeset
176 #if !(NGX_WIN32) /* the not regular files are probably Unix specific */
176
c0552e5ab567 nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents: 170
diff changeset
177
1454
f497ed7682a7 open_file_cache in HTTP
Igor Sysoev <igor@sysoev.ru>
parents: 1374
diff changeset
178 if (!of.is_file) {
3498
9f20a6e758c3 do not log misleading errno in "not a regular file" error
Igor Sysoev <igor@sysoev.ru>
parents: 3313
diff changeset
179 ngx_log_error(NGX_LOG_CRIT, log, 0,
557
ecd9c160f25b nginx-0.3.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 553
diff changeset
180 "\"%s\" is not a regular file", path.data);
176
c0552e5ab567 nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents: 170
diff changeset
181
c0552e5ab567 nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents: 170
diff changeset
182 return NGX_HTTP_NOT_FOUND;
c0552e5ab567 nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents: 170
diff changeset
183 }
c0552e5ab567 nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents: 170
diff changeset
184
c0552e5ab567 nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents: 170
diff changeset
185 #endif
c0552e5ab567 nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents: 170
diff changeset
186
2444
aee735f41627 set r->root_tested for non-error_page response only
Igor Sysoev <igor@sysoev.ru>
parents: 2231
diff changeset
187 r->root_tested = !r->error_page;
2087
c8039b26a949 always test root existence for access_log with variables
Igor Sysoev <igor@sysoev.ru>
parents: 2068
diff changeset
188
1790
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
189 rc = ngx_http_discard_request_body(r);
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
190
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
191 if (rc != NGX_OK) {
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
192 return rc;
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
193 }
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
194
509
9b8c906f6e63 nginx-0.1.29-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 501
diff changeset
195 log->action = "sending response to client";
148
5afee0074707 nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 143
diff changeset
196
201
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents: 200
diff changeset
197 r->headers_out.status = NGX_HTTP_OK;
1454
f497ed7682a7 open_file_cache in HTTP
Igor Sysoev <igor@sysoev.ru>
parents: 1374
diff changeset
198 r->headers_out.content_length_n = of.size;
f497ed7682a7 open_file_cache in HTTP
Igor Sysoev <igor@sysoev.ru>
parents: 1374
diff changeset
199 r->headers_out.last_modified_time = of.mtime;
201
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents: 200
diff changeset
200
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents: 200
diff changeset
201 if (ngx_http_set_content_type(r) != NGX_OK) {
200
abeaebe0a33c nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents: 199
diff changeset
202 return NGX_HTTP_INTERNAL_SERVER_ERROR;
abeaebe0a33c nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents: 199
diff changeset
203 }
abeaebe0a33c nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents: 199
diff changeset
204
1790
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
205 h = ngx_list_push(&r->headers_out.headers);
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
206 if (h == NULL) {
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
207 return NGX_ERROR;
583
4e296b7d25bf nginx-0.3.13-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 581
diff changeset
208 }
4e296b7d25bf nginx-0.3.13-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 581
diff changeset
209
1790
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
210 h->hash = 1;
3516
dd1570b6f237 ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents: 3498
diff changeset
211 ngx_str_set(&h->key, "Content-Encoding");
dd1570b6f237 ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents: 3498
diff changeset
212 ngx_str_set(&h->value, "gzip");
dd1570b6f237 ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents: 3498
diff changeset
213 r->headers_out.content_encoding = h;
1790
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
214
2877
3cd2790f4a9b add charset for ngx_http_gzip_static_module responses
Igor Sysoev <igor@sysoev.ru>
parents: 2756
diff changeset
215 r->ignore_content_encoding = 1;
1790
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
216
577
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 573
diff changeset
217 /* we need to allocate all before the header would be sent */
1
d220029ac7f3 nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
218
577
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 573
diff changeset
219 b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t));
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 573
diff changeset
220 if (b == NULL) {
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 573
diff changeset
221 return NGX_HTTP_INTERNAL_SERVER_ERROR;
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 573
diff changeset
222 }
26
53cb81681040 nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents: 24
diff changeset
223
577
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 573
diff changeset
224 b->file = ngx_pcalloc(r->pool, sizeof(ngx_file_t));
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 573
diff changeset
225 if (b->file == NULL) {
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 573
diff changeset
226 return NGX_HTTP_INTERNAL_SERVER_ERROR;
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 573
diff changeset
227 }
403
ea3113b181d1 nginx-0.0.9-2004-07-28-23:21:26 import
Igor Sysoev <igor@sysoev.ru>
parents: 400
diff changeset
228
96
a23d010f356d nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 89
diff changeset
229 rc = ngx_http_send_header(r);
143
5526213be452 nginx-0.0.1-2003-10-10-19:10:50 import
Igor Sysoev <igor@sysoev.ru>
parents: 142
diff changeset
230
585
401de5a43ba5 nginx-0.3.14-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 583
diff changeset
231 if (rc == NGX_ERROR || rc > NGX_OK || r->header_only) {
143
5526213be452 nginx-0.0.1-2003-10-10-19:10:50 import
Igor Sysoev <igor@sysoev.ru>
parents: 142
diff changeset
232 return rc;
99
a059e1aa65d4 nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents: 96
diff changeset
233 }
96
a23d010f356d nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 89
diff changeset
234
343
6bdf858bff8c nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents: 334
diff changeset
235 b->file_pos = 0;
1454
f497ed7682a7 open_file_cache in HTTP
Igor Sysoev <igor@sysoev.ru>
parents: 1374
diff changeset
236 b->file_last = of.size;
1
d220029ac7f3 nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
237
1790
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
238 b->in_file = b->file_last ? 1 : 0;
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
239 b->last_buf = 1;
577
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 573
diff changeset
240 b->last_in_chain = 1;
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 573
diff changeset
241
1696
f5f124fbfa3b delete useless variable
Igor Sysoev <igor@sysoev.ru>
parents: 1457
diff changeset
242 b->file->fd = of.fd;
557
ecd9c160f25b nginx-0.3.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 553
diff changeset
243 b->file->name = path;
343
6bdf858bff8c nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents: 334
diff changeset
244 b->file->log = log;
2231
8564129d49b6 *) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents: 2129
diff changeset
245 b->file->directio = of.is_directio;
343
6bdf858bff8c nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents: 334
diff changeset
246
6bdf858bff8c nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents: 334
diff changeset
247 out.buf = b;
153
c71aeb75c071 nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents: 148
diff changeset
248 out.next = NULL;
c71aeb75c071 nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents: 148
diff changeset
249
c71aeb75c071 nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents: 148
diff changeset
250 return ngx_http_output_filter(r, &out);
1
d220029ac7f3 nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
251 }
148
5afee0074707 nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 143
diff changeset
252
5afee0074707 nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 143
diff changeset
253
1790
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
254 static void *
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
255 ngx_http_gzip_static_create_conf(ngx_conf_t *cf)
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
256 {
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
257 ngx_http_gzip_static_conf_t *conf;
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
258
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
259 conf = ngx_palloc(cf->pool, sizeof(ngx_http_gzip_static_conf_t));
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
260 if (conf == NULL) {
2912
c7d57b539248 return NULL instead of NGX_CONF_ERROR on a create conf failure
Igor Sysoev <igor@sysoev.ru>
parents: 2877
diff changeset
261 return NULL;
1790
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
262 }
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
263
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
264 conf->enable = NGX_CONF_UNSET;
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
265
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
266 return conf;
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
267 }
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
268
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
269
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
270 static char *
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
271 ngx_http_gzip_static_merge_conf(ngx_conf_t *cf, void *parent, void *child)
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
272 {
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
273 ngx_http_gzip_static_conf_t *prev = parent;
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
274 ngx_http_gzip_static_conf_t *conf = child;
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
275
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
276 ngx_conf_merge_value(conf->enable, prev->enable, 0);
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
277
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
278 return NGX_CONF_OK;
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
279 }
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
280
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
281
509
9b8c906f6e63 nginx-0.1.29-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 501
diff changeset
282 static ngx_int_t
1790
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
283 ngx_http_gzip_static_init(ngx_conf_t *cf)
148
5afee0074707 nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 143
diff changeset
284 {
5afee0074707 nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 143
diff changeset
285 ngx_http_handler_pt *h;
5afee0074707 nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 143
diff changeset
286 ngx_http_core_main_conf_t *cmcf;
396
6f3b20c1ac50 nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
287
681
7e24168b0853 nginx-0.4.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 645
diff changeset
288 cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);
577
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 573
diff changeset
289
501
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 499
diff changeset
290 h = ngx_array_push(&cmcf->phases[NGX_HTTP_CONTENT_PHASE].handlers);
201
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents: 200
diff changeset
291 if (h == NULL) {
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents: 200
diff changeset
292 return NGX_ERROR;
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents: 200
diff changeset
293 }
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents: 200
diff changeset
294
1790
775edc46ee66 ngx_http_gzip_static_module and gzip_disable
Igor Sysoev <igor@sysoev.ru>
parents: 1772
diff changeset
295 *h = ngx_http_gzip_static_handler;
148
5afee0074707 nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 143
diff changeset
296
5afee0074707 nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 143
diff changeset
297 return NGX_OK;
5afee0074707 nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 143
diff changeset
298 }