comparison src/http/modules/ngx_http_static_module.c @ 126:df17fbafec8f NGINX_0_3_10

nginx 0.3.10 *) Change: the "valid_referers" directive and the "$invalid_referer" variable were moved to the new ngx_http_referer_module from the ngx_http_rewrite_module. *) Change: the "$apache_bytes_sent" variable name was changed to "$body_bytes_sent". *) Feature: the "$sent_http_..." variables. *) Feature: the "if" directive supports the "=" and "!=" operations. *) Feature: the "proxy_pass" directive supports the HTTPS protocol. *) Feature: the "proxy_set_body" directive. *) Feature: the "post_action" directive. *) Feature: the ngx_http_empty_gif_module. *) Feature: the "worker_cpu_affinity" directive for Linux. *) Bugfix: the "rewrite" directive did not unescape URI part in redirect, now it is unescaped except the %00-%25 and %7F-%FF characters. *) Bugfix: nginx could not be built by the icc 9.0 compiler. *) Bugfix: if the SSI was enabled for zero size static file, then the chunked response was encoded incorrectly.
author Igor Sysoev <http://sysoev.ru>
date Tue, 15 Nov 2005 00:00:00 +0300
parents d25a1d6034f1
children 82d695e3d662
comparison
equal deleted inserted replaced
125:97504de1f89e 126:df17fbafec8f
42 NULL, /* preconfiguration */ 42 NULL, /* preconfiguration */
43 NULL, /* postconfiguration */ 43 NULL, /* postconfiguration */
44 44
45 NULL, /* create main configuration */ 45 NULL, /* create main configuration */
46 NULL, /* init main configuration */ 46 NULL, /* init main configuration */
47 47
48 NULL, /* create server configuration */ 48 NULL, /* create server configuration */
49 NULL, /* merge server configuration */ 49 NULL, /* merge server configuration */
50 50
51 ngx_http_static_create_loc_conf, /* create location configuration */ 51 ngx_http_static_create_loc_conf, /* create location configuration */
52 ngx_http_static_merge_loc_conf /* merge location configuration */ 52 ngx_http_static_merge_loc_conf /* merge location configuration */
53 }; 53 };
54 54
55 55
56 ngx_module_t ngx_http_static_module = { 56 ngx_module_t ngx_http_static_module = {
57 NGX_MODULE_V1, 57 NGX_MODULE_V1,
58 &ngx_http_static_module_ctx, /* module context */ 58 &ngx_http_static_module_ctx, /* module context */
238 238
239 r->headers_out.status = NGX_HTTP_OK; 239 r->headers_out.status = NGX_HTTP_OK;
240 r->headers_out.content_length_n = ngx_file_size(&fi); 240 r->headers_out.content_length_n = ngx_file_size(&fi);
241 r->headers_out.last_modified_time = ngx_file_mtime(&fi); 241 r->headers_out.last_modified_time = ngx_file_mtime(&fi);
242 242
243 if (r->headers_out.content_length_n == 0) {
244 r->header_only = 1;
245 }
246
247 if (ngx_http_set_content_type(r) != NGX_OK) { 243 if (ngx_http_set_content_type(r) != NGX_OK) {
248 return NGX_HTTP_INTERNAL_SERVER_ERROR; 244 return NGX_HTTP_INTERNAL_SERVER_ERROR;
249 } 245 }
250 246
251 #if (NGX_SUPPRESS_WARN) 247 /* we need to allocate all before the header would be sent */
252 b = NULL; 248
253 #endif 249 b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t));
254 250 if (b == NULL) {
255 if (!r->header_only) { 251 return NGX_HTTP_INTERNAL_SERVER_ERROR;
256 /* we need to allocate all before the header would be sent */ 252 }
257 253
258 b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t)); 254 b->file = ngx_pcalloc(r->pool, sizeof(ngx_file_t));
259 if (b == NULL) { 255 if (b->file == NULL) {
260 return NGX_HTTP_INTERNAL_SERVER_ERROR; 256 return NGX_HTTP_INTERNAL_SERVER_ERROR;
261 } 257 }
262 258
263 b->file = ngx_pcalloc(r->pool, sizeof(ngx_file_t)); 259 r->filter_allow_ranges = 1;
264 if (b->file == NULL) {
265 return NGX_HTTP_INTERNAL_SERVER_ERROR;
266 }
267
268 r->filter_allow_ranges = 1;
269 }
270 260
271 rc = ngx_http_send_header(r); 261 rc = ngx_http_send_header(r);
272 262
273 if (rc == NGX_ERROR || rc > NGX_OK || r->header_only) { 263 if (rc == NGX_ERROR || rc > NGX_OK || r->header_only) {
274 return rc; 264 return rc;
275 } 265 }
276 266
277 b->in_file = 1;
278
279 if (r->main == r) {
280 b->last_buf = 1;
281 }
282
283 b->last_in_chain = 1;
284
285 b->file_pos = 0; 267 b->file_pos = 0;
286 b->file_last = ngx_file_size(&fi); 268 b->file_last = ngx_file_size(&fi);
269
270 b->in_file = b->file_last ? 1: 0;
271 b->last_buf = (r->main == r) ? 1: 0;
272 b->last_in_chain = 1;
287 273
288 b->file->fd = fd; 274 b->file->fd = fd;
289 b->file->name = path; 275 b->file->name = path;
290 b->file->log = log; 276 b->file->log = log;
291 277
331 { 317 {
332 ngx_http_handler_pt *h; 318 ngx_http_handler_pt *h;
333 ngx_http_core_main_conf_t *cmcf; 319 ngx_http_core_main_conf_t *cmcf;
334 320
335 cmcf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_core_module); 321 cmcf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_core_module);
336 322
337 h = ngx_array_push(&cmcf->phases[NGX_HTTP_CONTENT_PHASE].handlers); 323 h = ngx_array_push(&cmcf->phases[NGX_HTTP_CONTENT_PHASE].handlers);
338 if (h == NULL) { 324 if (h == NULL) {
339 return NGX_ERROR; 325 return NGX_ERROR;
340 } 326 }
341 327