Mercurial > hg > nginx
comparison src/http/modules/ngx_http_range_filter_module.c @ 509:9b8c906f6e63 release-0.1.29
nginx-0.1.29-RELEASE import
*) Feature: the ngx_http_ssi_module supports "include virtual" command.
*) Feature: the ngx_http_ssi_module supports the condition command like
'if expr="$NAME"' and "else" and "endif" commands. Only one nested
level is supported.
*) Feature: the ngx_http_ssi_module supports the DATE_LOCAL and
DATE_GMT variables and "config timefmt" command.
*) Feature: the "ssi_ignore_recycled_buffers" directive.
*) Bugfix: the "echo" command did not show the default value for the
empty QUERY_STRING variable.
*) Change: the ngx_http_proxy_module was rewritten.
*) Feature: the "proxy_redirect", "proxy_pass_request_headers",
"proxy_pass_request_body", and "proxy_method" directives.
*) Feature: the "proxy_set_header" directive. The "proxy_x_var" was
canceled and must be replaced with the proxy_set_header directive.
*) Change: the "proxy_preserve_host" is canceled and must be replaced
with the "proxy_set_header Host $host" and the "proxy_redirect off"
directives, the "proxy_set_header Host $host:$proxy_port" directive
and the appropriate proxy_redirect directives.
*) Change: the "proxy_set_x_real_ip" is canceled and must be replaced
with the "proxy_set_header X-Real-IP $remote_addr" directive.
*) Change: the "proxy_add_x_forwarded_for" is canceled and must be
replaced with
the "proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for"
directive.
*) Change: the "proxy_set_x_url" is canceled and must be replaced with
the "proxy_set_header X-URL http://$host:$server_port$request_uri"
directive.
*) Feature: the "fastcgi_param" directive.
*) Change: the "fastcgi_root", "fastcgi_set_var" and "fastcgi_params"
directive are canceled and must be replaced with the fastcgi_param
directives.
*) Feature: the "index" directive can use the variables.
*) Feature: the "index" directive can be used at http and server levels.
*) Change: the last index only in the "index" directive can be absolute.
*) Feature: the "rewrite" directive can use the variables.
*) Feature: the "internal" directive.
*) Feature: the CONTENT_LENGTH, CONTENT_TYPE, REMOTE_PORT, SERVER_ADDR,
SERVER_PORT, SERVER_PROTOCOL, DOCUMENT_ROOT, SERVER_NAME,
REQUEST_METHOD, REQUEST_URI, and REMOTE_USER variables.
*) Change: nginx now passes the invalid lines in a client request
headers or a backend response header.
*) Bugfix: if the backend did not transfer response for a long time and
the "send_timeout" was less than "proxy_read_timeout", then nginx
returned the 408 response.
*) Bugfix: the segmentation fault was occurred if the backend sent an
invalid line in response header; the bug had appeared in 0.1.26.
*) Bugfix: the segmentation fault may occurred in FastCGI fault
tolerance configuration.
*) Bugfix: the "expires" directive did not remove the previous
"Expires" and "Cache-Control" headers.
*) Bugfix: nginx did not take into account trailing dot in "Host"
header line.
*) Bugfix: the ngx_http_auth_module did not work under Linux.
*) Bugfix: the rewrite directive worked incorrectly, if the arguments
were in a request.
*) Bugfix: nginx could not be built on MacOS X.
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Thu, 12 May 2005 14:58:06 +0000 |
parents | d4ea69372b94 |
children | b09ee85d0ac8 |
comparison
equal
deleted
inserted
replaced
508:ca1020ce99ba | 509:9b8c906f6e63 |
---|---|
52 static ngx_int_t ngx_http_range_header_filter_init(ngx_cycle_t *cycle); | 52 static ngx_int_t ngx_http_range_header_filter_init(ngx_cycle_t *cycle); |
53 static ngx_int_t ngx_http_range_body_filter_init(ngx_cycle_t *cycle); | 53 static ngx_int_t ngx_http_range_body_filter_init(ngx_cycle_t *cycle); |
54 | 54 |
55 | 55 |
56 static ngx_http_module_t ngx_http_range_header_filter_module_ctx = { | 56 static ngx_http_module_t ngx_http_range_header_filter_module_ctx = { |
57 NULL, /* pre conf */ | 57 NULL, /* preconfiguration */ |
58 NULL, /* postconfiguration */ | |
58 | 59 |
59 NULL, /* create main configuration */ | 60 NULL, /* create main configuration */ |
60 NULL, /* init main configuration */ | 61 NULL, /* init main configuration */ |
61 | 62 |
62 NULL, /* create server configuration */ | 63 NULL, /* create server configuration */ |
66 NULL, /* merge location configuration */ | 67 NULL, /* merge location configuration */ |
67 }; | 68 }; |
68 | 69 |
69 | 70 |
70 ngx_module_t ngx_http_range_header_filter_module = { | 71 ngx_module_t ngx_http_range_header_filter_module = { |
71 NGX_MODULE, | 72 NGX_MODULE_V1, |
72 &ngx_http_range_header_filter_module_ctx, /* module context */ | 73 &ngx_http_range_header_filter_module_ctx, /* module context */ |
73 NULL, /* module directives */ | 74 NULL, /* module directives */ |
74 NGX_HTTP_MODULE, /* module type */ | 75 NGX_HTTP_MODULE, /* module type */ |
75 ngx_http_range_header_filter_init, /* init module */ | 76 ngx_http_range_header_filter_init, /* init module */ |
76 NULL /* init process */ | 77 NULL /* init process */ |
77 }; | 78 }; |
78 | 79 |
79 | 80 |
80 static ngx_http_module_t ngx_http_range_body_filter_module_ctx = { | 81 static ngx_http_module_t ngx_http_range_body_filter_module_ctx = { |
81 NULL, /* pre conf */ | 82 NULL, /* preconfiguration */ |
83 NULL, /* postconfiguration */ | |
82 | 84 |
83 NULL, /* create main configuration */ | 85 NULL, /* create main configuration */ |
84 NULL, /* init main configuration */ | 86 NULL, /* init main configuration */ |
85 | 87 |
86 NULL, /* create server configuration */ | 88 NULL, /* create server configuration */ |
90 NULL, /* merge location configuration */ | 92 NULL, /* merge location configuration */ |
91 }; | 93 }; |
92 | 94 |
93 | 95 |
94 ngx_module_t ngx_http_range_body_filter_module = { | 96 ngx_module_t ngx_http_range_body_filter_module = { |
95 NGX_MODULE, | 97 NGX_MODULE_V1, |
96 &ngx_http_range_body_filter_module_ctx, /* module context */ | 98 &ngx_http_range_body_filter_module_ctx, /* module context */ |
97 NULL, /* module directives */ | 99 NULL, /* module directives */ |
98 NGX_HTTP_MODULE, /* module type */ | 100 NGX_HTTP_MODULE, /* module type */ |
99 ngx_http_range_body_filter_init, /* init module */ | 101 ngx_http_range_body_filter_init, /* init module */ |
100 NULL /* init process */ | 102 NULL /* init process */ |
118 ngx_http_range_t *range; | 120 ngx_http_range_t *range; |
119 ngx_http_range_filter_ctx_t *ctx; | 121 ngx_http_range_filter_ctx_t *ctx; |
120 | 122 |
121 if (r->http_version < NGX_HTTP_VERSION_10 | 123 if (r->http_version < NGX_HTTP_VERSION_10 |
122 || r->headers_out.status != NGX_HTTP_OK | 124 || r->headers_out.status != NGX_HTTP_OK |
125 || r->main | |
123 || r->headers_out.content_length_n == -1 | 126 || r->headers_out.content_length_n == -1 |
124 || !r->filter_allow_ranges) | 127 || !r->filter_allow_ranges) |
125 { | 128 { |
126 return ngx_http_next_header_filter(r); | 129 return ngx_http_next_header_filter(r); |
127 } | 130 } |
134 r->headers_out.accept_ranges = ngx_list_push(&r->headers_out.headers); | 137 r->headers_out.accept_ranges = ngx_list_push(&r->headers_out.headers); |
135 if (r->headers_out.accept_ranges == NULL) { | 138 if (r->headers_out.accept_ranges == NULL) { |
136 return NGX_ERROR; | 139 return NGX_ERROR; |
137 } | 140 } |
138 | 141 |
142 r->headers_out.accept_ranges->hash = 1; | |
139 r->headers_out.accept_ranges->key.len = sizeof("Accept-Ranges") - 1; | 143 r->headers_out.accept_ranges->key.len = sizeof("Accept-Ranges") - 1; |
140 r->headers_out.accept_ranges->key.data = (u_char *) "Accept-Ranges"; | 144 r->headers_out.accept_ranges->key.data = (u_char *) "Accept-Ranges"; |
141 r->headers_out.accept_ranges->value.len = sizeof("bytes") - 1; | 145 r->headers_out.accept_ranges->value.len = sizeof("bytes") - 1; |
142 r->headers_out.accept_ranges->value.data = (u_char *) "bytes"; | 146 r->headers_out.accept_ranges->value.data = (u_char *) "bytes"; |
143 | 147 |
267 return NGX_ERROR; | 271 return NGX_ERROR; |
268 } | 272 } |
269 | 273 |
270 r->headers_out.content_range = content_range; | 274 r->headers_out.content_range = content_range; |
271 | 275 |
276 content_range->hash = 1; | |
272 content_range->key.len = sizeof("Content-Range") - 1; | 277 content_range->key.len = sizeof("Content-Range") - 1; |
273 content_range->key.data = (u_char *) "Content-Range"; | 278 content_range->key.data = (u_char *) "Content-Range"; |
274 | 279 |
275 content_range->value.data = ngx_palloc(r->pool, | 280 content_range->value.data = ngx_palloc(r->pool, |
276 sizeof("bytes */") - 1 + NGX_OFF_T_LEN); | 281 sizeof("bytes */") - 1 + NGX_OFF_T_LEN); |
301 return NGX_ERROR; | 306 return NGX_ERROR; |
302 } | 307 } |
303 | 308 |
304 r->headers_out.content_range = content_range; | 309 r->headers_out.content_range = content_range; |
305 | 310 |
311 content_range->hash = 1; | |
306 content_range->key.len = sizeof("Content-Range") - 1; | 312 content_range->key.len = sizeof("Content-Range") - 1; |
307 content_range->key.data = (u_char *) "Content-Range"; | 313 content_range->key.data = (u_char *) "Content-Range"; |
308 | 314 |
309 content_range->value.data = | 315 content_range->value.data = |
310 ngx_palloc(r->pool, sizeof("bytes -/") - 1 + 3 * NGX_OFF_T_LEN); | 316 ngx_palloc(r->pool, sizeof("bytes -/") - 1 + 3 * NGX_OFF_T_LEN); |
336 ngx_http_set_ctx(r, ctx, ngx_http_range_body_filter_module); | 342 ngx_http_set_ctx(r, ctx, ngx_http_range_body_filter_module); |
337 | 343 |
338 | 344 |
339 len = sizeof(CRLF "--") - 1 + NGX_ATOMIC_T_LEN | 345 len = sizeof(CRLF "--") - 1 + NGX_ATOMIC_T_LEN |
340 + sizeof(CRLF "Content-Type: ") - 1 | 346 + sizeof(CRLF "Content-Type: ") - 1 |
341 + r->headers_out.content_type->value.len | 347 + r->headers_out.content_type.len |
342 + sizeof(CRLF "Content-Range: bytes ") - 1; | 348 + sizeof(CRLF "Content-Range: bytes ") - 1; |
343 | 349 |
344 if (r->headers_out.charset.len) { | 350 if (r->headers_out.charset.len) { |
345 len += sizeof("; charset=") - 1 + r->headers_out.charset.len; | 351 len += sizeof("; charset=") - 1 + r->headers_out.charset.len; |
346 } | 352 } |
364 ctx->boundary_header.len = ngx_sprintf(ctx->boundary_header.data, | 370 ctx->boundary_header.len = ngx_sprintf(ctx->boundary_header.data, |
365 CRLF "--%0muA" CRLF | 371 CRLF "--%0muA" CRLF |
366 "Content-Type: %V; charset=%V" CRLF | 372 "Content-Type: %V; charset=%V" CRLF |
367 "Content-Range: bytes ", | 373 "Content-Range: bytes ", |
368 boundary, | 374 boundary, |
369 &r->headers_out.content_type->value, | 375 &r->headers_out.content_type, |
370 &r->headers_out.charset) | 376 &r->headers_out.charset) |
371 - ctx->boundary_header.data; | 377 - ctx->boundary_header.data; |
372 | 378 |
373 r->headers_out.charset.len = 0; | 379 r->headers_out.charset.len = 0; |
374 | 380 |
376 ctx->boundary_header.len = ngx_sprintf(ctx->boundary_header.data, | 382 ctx->boundary_header.len = ngx_sprintf(ctx->boundary_header.data, |
377 CRLF "--%0muA" CRLF | 383 CRLF "--%0muA" CRLF |
378 "Content-Type: %V" CRLF | 384 "Content-Type: %V" CRLF |
379 "Content-Range: bytes ", | 385 "Content-Range: bytes ", |
380 boundary, | 386 boundary, |
381 &r->headers_out.content_type->value) | 387 &r->headers_out.content_type) |
382 - ctx->boundary_header.data; | 388 - ctx->boundary_header.data; |
383 } | 389 } |
384 | 390 |
385 r->headers_out.content_type->value.data = | 391 r->headers_out.content_type.data = |
386 ngx_palloc(r->pool, | 392 ngx_palloc(r->pool, |
387 sizeof("Content-Type: multipart/byteranges; boundary=") - 1 | 393 sizeof("Content-Type: multipart/byteranges; boundary=") - 1 |
388 + NGX_ATOMIC_T_LEN); | 394 + NGX_ATOMIC_T_LEN); |
389 | 395 |
390 if (r->headers_out.content_type->value.data == NULL) { | 396 if (r->headers_out.content_type.data == NULL) { |
391 return NGX_ERROR; | 397 return NGX_ERROR; |
392 } | 398 } |
393 | 399 |
394 /* "Content-Type: multipart/byteranges; boundary=0123456789" */ | 400 /* "Content-Type: multipart/byteranges; boundary=0123456789" */ |
395 | 401 |
396 r->headers_out.content_type->value.len = | 402 r->headers_out.content_type.len = |
397 ngx_sprintf(r->headers_out.content_type->value.data, | 403 ngx_sprintf(r->headers_out.content_type.data, |
398 "multipart/byteranges; boundary=%0muA", | 404 "multipart/byteranges; boundary=%0muA", |
399 boundary) | 405 boundary) |
400 - r->headers_out.content_type->value.data; | 406 - r->headers_out.content_type.data; |
401 | 407 |
402 | 408 |
403 /* the size of the last boundary CRLF "--0123456789--" CRLF */ | 409 /* the size of the last boundary CRLF "--0123456789--" CRLF */ |
404 | 410 |
405 len = sizeof(CRLF "--") - 1 + NGX_ATOMIC_T_LEN + sizeof("--" CRLF) - 1; | 411 len = sizeof(CRLF "--") - 1 + NGX_ATOMIC_T_LEN + sizeof("--" CRLF) - 1; |