Mercurial > hg > nginx-mail
comparison src/http/modules/ngx_http_gzip_static_module.c @ 665:0b460e61bdcd default tip
Merge with nginx 1.0.0.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 25 Apr 2011 04:22:17 +0400 |
parents | ff463db0be31 |
children |
comparison
equal
deleted
inserted
replaced
572:06419a2298a9 | 665:0b460e61bdcd |
---|---|
87 | 87 |
88 if (r->uri.data[r->uri.len - 1] == '/') { | 88 if (r->uri.data[r->uri.len - 1] == '/') { |
89 return NGX_DECLINED; | 89 return NGX_DECLINED; |
90 } | 90 } |
91 | 91 |
92 if (r->zero_in_uri) { | |
93 return NGX_DECLINED; | |
94 } | |
95 | |
96 gzcf = ngx_http_get_module_loc_conf(r, ngx_http_gzip_static_module); | 92 gzcf = ngx_http_get_module_loc_conf(r, ngx_http_gzip_static_module); |
97 | 93 |
98 if (!gzcf->enable) { | 94 if (!gzcf->enable) { |
99 return NGX_DECLINED; | 95 return NGX_DECLINED; |
100 } | 96 } |
101 | 97 |
98 rc = ngx_http_gzip_ok(r); | |
99 | |
102 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); | 100 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); |
103 | 101 |
104 if (clcf->gzip_vary && ngx_http_gzip_ok(r) != NGX_OK) { | 102 if (!clcf->gzip_vary && rc != NGX_OK) { |
105 return NGX_DECLINED; | 103 return NGX_DECLINED; |
106 } | 104 } |
107 | 105 |
108 log = r->connection->log; | 106 log = r->connection->log; |
109 | 107 |
122 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, log, 0, | 120 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, log, 0, |
123 "http filename: \"%s\"", path.data); | 121 "http filename: \"%s\"", path.data); |
124 | 122 |
125 ngx_memzero(&of, sizeof(ngx_open_file_info_t)); | 123 ngx_memzero(&of, sizeof(ngx_open_file_info_t)); |
126 | 124 |
125 of.read_ahead = clcf->read_ahead; | |
127 of.directio = clcf->directio; | 126 of.directio = clcf->directio; |
128 of.valid = clcf->open_file_cache_valid; | 127 of.valid = clcf->open_file_cache_valid; |
129 of.min_uses = clcf->open_file_cache_min_uses; | 128 of.min_uses = clcf->open_file_cache_min_uses; |
130 of.errors = clcf->open_file_cache_errors; | 129 of.errors = clcf->open_file_cache_errors; |
131 of.events = clcf->open_file_cache_events; | 130 of.events = clcf->open_file_cache_events; |
140 | 139 |
141 case NGX_ENOENT: | 140 case NGX_ENOENT: |
142 case NGX_ENOTDIR: | 141 case NGX_ENOTDIR: |
143 case NGX_ENAMETOOLONG: | 142 case NGX_ENAMETOOLONG: |
144 | 143 |
145 r->gzip = 0; | |
146 return NGX_DECLINED; | 144 return NGX_DECLINED; |
147 | 145 |
148 case NGX_EACCES: | 146 case NGX_EACCES: |
149 | 147 |
150 level = NGX_LOG_ERR; | 148 level = NGX_LOG_ERR; |
160 "%s \"%s\" failed", of.failed, path.data); | 158 "%s \"%s\" failed", of.failed, path.data); |
161 | 159 |
162 return NGX_DECLINED; | 160 return NGX_DECLINED; |
163 } | 161 } |
164 | 162 |
163 r->gzip_vary = 1; | |
164 | |
165 if (rc != NGX_OK) { | |
166 return NGX_DECLINED; | |
167 } | |
168 | |
165 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, log, 0, "http static fd: %d", of.fd); | 169 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, log, 0, "http static fd: %d", of.fd); |
166 | 170 |
167 if (of.is_dir) { | 171 if (of.is_dir) { |
168 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, log, 0, "http dir"); | 172 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, log, 0, "http dir"); |
169 return NGX_DECLINED; | 173 return NGX_DECLINED; |
170 } | 174 } |
171 | 175 |
172 #if !(NGX_WIN32) /* the not regular files are probably Unix specific */ | 176 #if !(NGX_WIN32) /* the not regular files are probably Unix specific */ |
173 | 177 |
174 if (!of.is_file) { | 178 if (!of.is_file) { |
175 ngx_log_error(NGX_LOG_CRIT, log, ngx_errno, | 179 ngx_log_error(NGX_LOG_CRIT, log, 0, |
176 "\"%s\" is not a regular file", path.data); | 180 "\"%s\" is not a regular file", path.data); |
177 | 181 |
178 return NGX_HTTP_NOT_FOUND; | 182 return NGX_HTTP_NOT_FOUND; |
179 } | 183 } |
180 | 184 |
202 if (h == NULL) { | 206 if (h == NULL) { |
203 return NGX_ERROR; | 207 return NGX_ERROR; |
204 } | 208 } |
205 | 209 |
206 h->hash = 1; | 210 h->hash = 1; |
207 h->key.len = sizeof("Content-Encoding") - 1; | 211 ngx_str_set(&h->key, "Content-Encoding"); |
208 h->key.data = (u_char *) "Content-Encoding"; | 212 ngx_str_set(&h->value, "gzip"); |
209 h->value.len = sizeof("gzip") - 1; | |
210 h->value.data = (u_char *) "gzip"; | |
211 | |
212 r->headers_out.content_encoding = h; | 213 r->headers_out.content_encoding = h; |
214 | |
213 r->ignore_content_encoding = 1; | 215 r->ignore_content_encoding = 1; |
214 | 216 |
215 /* we need to allocate all before the header would be sent */ | 217 /* we need to allocate all before the header would be sent */ |
216 | 218 |
217 b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t)); | 219 b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t)); |