comparison src/http/ngx_http_request.c @ 130:82d695e3d662 NGINX_0_3_12

nginx 0.3.12 *) Security: if nginx was built with the ngx_http_realip_module and the "satisfy_any on" directive was used, then access and authorization directives did not work. The ngx_http_realip_module was not built and is not built by default. *) Change: the "$time_gmt" variable name was changed to "$time_local". *) Change: the "proxy_header_buffer_size" and "fastcgi_header_buffer_size" directives was renamed to the "proxy_buffer_size" and "fastcgi_buffer_size" directives. *) Feature: the ngx_http_memcached_module. *) Feature: the "proxy_buffering" directive. *) Bugfix: the changes in accept mutex handling when the "rtsig" method was used; bug appeared in 0.3.0. *) Bugfix: if the client sent the "Transfer-Encoding: chunked" header line, then nginx returns the 411 error. *) Bugfix: if the "auth_basic" directive was inherited from the http level, then the realm in the "WWW-Authenticate" header line was without the "Basic realm" text. *) Bugfix: if the "combined" format was explicitly specified in the "access_log" directive, then the empty lines was written to the log; bug appeared in 0.3.8. *) Bugfix: nginx did not run on the sparc platform under any OS except Solaris. *) Bugfix: now it is not necessary to place space between the quoted string and closing bracket in the "if" directive.
author Igor Sysoev <http://sysoev.ru>
date Sat, 26 Nov 2005 00:00:00 +0300
parents df17fbafec8f
children 91372f004adf
comparison
equal deleted inserted replaced
129:a27c77ef3ad8 130:82d695e3d662
91 { ngx_string("Content-Type"), 91 { ngx_string("Content-Type"),
92 offsetof(ngx_http_headers_in_t, content_type), 92 offsetof(ngx_http_headers_in_t, content_type),
93 ngx_http_process_header_line }, 93 ngx_http_process_header_line },
94 94
95 { ngx_string("Range"), offsetof(ngx_http_headers_in_t, range), 95 { ngx_string("Range"), offsetof(ngx_http_headers_in_t, range),
96 ngx_http_process_header_line },
97
98 { ngx_string("Transfer-Encoding"),
99 offsetof(ngx_http_headers_in_t, transfer_encoding),
96 ngx_http_process_header_line }, 100 ngx_http_process_header_line },
97 101
98 #if (NGX_HTTP_GZIP) 102 #if (NGX_HTTP_GZIP)
99 { ngx_string("Accept-Encoding"), 103 { ngx_string("Accept-Encoding"),
100 offsetof(ngx_http_headers_in_t, accept_encoding), 104 offsetof(ngx_http_headers_in_t, accept_encoding),
375 return; 379 return;
376 } 380 }
377 381
378 382
379 if (ngx_list_init(&r->headers_out.headers, r->pool, 20, 383 if (ngx_list_init(&r->headers_out.headers, r->pool, 20,
380 sizeof(ngx_table_elt_t)) == NGX_ERROR) 384 sizeof(ngx_table_elt_t))
385 == NGX_ERROR)
381 { 386 {
382 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); 387 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
383 return; 388 return;
384 } 389 }
385 390
658 return; 663 return;
659 } 664 }
660 665
661 666
662 if (ngx_list_init(&r->headers_in.headers, r->pool, 20, 667 if (ngx_list_init(&r->headers_in.headers, r->pool, 20,
663 sizeof(ngx_table_elt_t)) == NGX_ERROR) 668 sizeof(ngx_table_elt_t))
669 == NGX_ERROR)
664 { 670 {
665 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); 671 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
666 return; 672 return;
667 } 673 }
668 674
669 675
670 if (ngx_array_init(&r->headers_in.cookies, r->pool, 2, 676 if (ngx_array_init(&r->headers_in.cookies, r->pool, 2,
671 sizeof(ngx_table_elt_t *)) == NGX_ERROR) 677 sizeof(ngx_table_elt_t *))
678 == NGX_ERROR)
672 { 679 {
673 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); 680 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
674 return; 681 return;
675 } 682 }
676 683
1211 r->headers_in.content_length->value.len); 1218 r->headers_in.content_length->value.len);
1212 1219
1213 if (r->headers_in.content_length_n == NGX_ERROR) { 1220 if (r->headers_in.content_length_n == NGX_ERROR) {
1214 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, 1221 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
1215 "client sent invalid \"Content-Length\" header"); 1222 "client sent invalid \"Content-Length\" header");
1216 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); 1223 ngx_http_finalize_request(r, NGX_HTTP_LENGTH_REQUIRED);
1217 return NGX_ERROR; 1224 return NGX_ERROR;
1218 } 1225 }
1219 } 1226 }
1220 1227
1221 if (r->method == NGX_HTTP_POST && r->headers_in.content_length_n == -1) { 1228 if (r->method == NGX_HTTP_POST && r->headers_in.content_length_n == -1) {
1222 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, 1229 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
1223 "client sent POST method without \"Content-Length\" header"); 1230 "client sent POST method without \"Content-Length\" header");
1224 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); 1231 ngx_http_finalize_request(r, NGX_HTTP_LENGTH_REQUIRED);
1232 return NGX_ERROR;
1233 }
1234
1235 if (r->headers_in.transfer_encoding
1236 && ngx_strstr(r->headers_in.transfer_encoding->value.data, "chunked"))
1237 {
1238 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
1239 "client sent \"Transfer-Encoding: chunked\" header");
1240 ngx_http_finalize_request(r, NGX_HTTP_LENGTH_REQUIRED);
1225 return NGX_ERROR; 1241 return NGX_ERROR;
1226 } 1242 }
1227 1243
1228 if (r->plain_http) { 1244 if (r->plain_http) {
1229 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, 1245 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
2093 } 2109 }
2094 2110
2095 #if (NGX_HAVE_KQUEUE) 2111 #if (NGX_HAVE_KQUEUE)
2096 2112
2097 if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) { 2113 if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
2098 if (rev->pending_eof) { 2114 if (rev->pending_eof
2115 /* FreeBSD 5.x-6.x may erroneously report ETIMEDOUT */
2116 && rev->kq_errno != NGX_ETIMEDOUT)
2117 {
2099 c->log->handler = NULL; 2118 c->log->handler = NULL;
2100 ngx_log_error(NGX_LOG_INFO, c->log, rev->kq_errno, 2119 ngx_log_error(NGX_LOG_INFO, c->log, rev->kq_errno,
2101 "kevent() reported that client %V closed " 2120 "kevent() reported that client %V closed "
2102 "keepalive connection", &c->addr_text); 2121 "keepalive connection", &c->addr_text);
2103 #if (NGX_HTTP_SSL) 2122 #if (NGX_HTTP_SSL)
2310 return; 2329 return;
2311 } 2330 }
2312 2331
2313 2332
2314 ngx_int_t 2333 ngx_int_t
2315 ngx_http_send_last(ngx_http_request_t *r) 2334 ngx_http_send_special(ngx_http_request_t *r, ngx_uint_t flags)
2316 { 2335 {
2317 ngx_buf_t *b; 2336 ngx_buf_t *b;
2318 ngx_chain_t out; 2337 ngx_chain_t out;
2319 2338
2320 b = ngx_calloc_buf(r->pool); 2339 b = ngx_calloc_buf(r->pool);
2321 if (b == NULL) { 2340 if (b == NULL) {
2322 return NGX_ERROR; 2341 return NGX_ERROR;
2323 } 2342 }
2324 2343
2325 b->last_buf = 1; 2344 if (flags & NGX_HTTP_LAST) {
2345 b->last_buf = 1;
2346 }
2347
2348 if (flags & NGX_HTTP_FLUSH) {
2349 b->flush = 1;
2350 }
2351
2326 out.buf = b; 2352 out.buf = b;
2327 out.next = NULL; 2353 out.next = NULL;
2328 2354
2329 return ngx_http_output_filter(r, &out); 2355 return ngx_http_output_filter(r, &out);
2330 } 2356 }
2352 2378
2353 void 2379 void
2354 ngx_http_request_done(ngx_http_request_t *r, ngx_int_t error) 2380 ngx_http_request_done(ngx_http_request_t *r, ngx_int_t error)
2355 { 2381 {
2356 ngx_log_t *log; 2382 ngx_log_t *log;
2383 ngx_uint_t i, n;
2357 struct linger linger; 2384 struct linger linger;
2358 ngx_http_log_ctx_t *ctx; 2385 ngx_http_log_ctx_t *ctx;
2386 ngx_http_handler_pt *log_handler;
2359 ngx_http_core_loc_conf_t *clcf; 2387 ngx_http_core_loc_conf_t *clcf;
2360 ngx_http_core_main_conf_t *cmcf; 2388 ngx_http_core_main_conf_t *cmcf;
2361 2389
2362 log = r->connection->log; 2390 log = r->connection->log;
2363 2391
2384 r->headers_out.status = error; 2412 r->headers_out.status = error;
2385 } 2413 }
2386 2414
2387 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module); 2415 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module);
2388 2416
2389 if (cmcf->log_handler) { 2417 log_handler = cmcf->phases[NGX_HTTP_LOG_PHASE].handlers.elts;
2390 cmcf->log_handler(r); 2418 n = cmcf->phases[NGX_HTTP_LOG_PHASE].handlers.nelts;
2419 for (i = 0; i < n; i++) {
2420 log_handler[i](r);
2391 } 2421 }
2392 2422
2393 if (r->connection->timedout) { 2423 if (r->connection->timedout) {
2394 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); 2424 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
2395 2425