Mercurial > hg > nginx-vendor-1-0
comparison src/http/ngx_http_request.c @ 362:54fad6c4b555 NGINX_0_6_25
nginx 0.6.25
*) Change: now the "server_name_in_redirect" directive is used instead
of the "server_name" directive's special "*" parameter.
*) Change: now wildcard and regex names can be used as main name in a
"server_name" directive.
*) Change: the "satisfy_any" directive was replaced by the "satisfy"
directive.
*) Workaround: old worker processes might hog CPU after reconfiguration
if they was run under Linux OpenVZ.
*) Feature: the "min_delete_depth" directive.
*) Bugfix: the COPY and MOVE methods did not work with single files.
*) Bugfix: the ngx_http_gzip_static_module did not allow the
ngx_http_dav_module to work; bug appeared in 0.6.23.
*) Bugfix: socket leak in HTTPS mode if deferred accept was used.
Thanks to Ben Maurer.
*) Bugfix: nginx could not be built without PCRE library; bug appeared
in 0.6.23.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Tue, 08 Jan 2008 00:00:00 +0300 |
parents | 9121a0a91f47 |
children | a39aab45a53f |
comparison
equal
deleted
inserted
replaced
361:160660bad929 | 362:54fad6c4b555 |
---|---|
171 if (ctx == NULL) { | 171 if (ctx == NULL) { |
172 ngx_http_close_connection(c); | 172 ngx_http_close_connection(c); |
173 return; | 173 return; |
174 } | 174 } |
175 | 175 |
176 ctx->client = &c->addr_text; | 176 ctx->connection = c; |
177 ctx->request = NULL; | 177 ctx->request = NULL; |
178 ctx->current_request = NULL; | 178 ctx->current_request = NULL; |
179 | 179 |
180 c->log->connection = c->number; | 180 c->log->connection = c->number; |
181 c->log->handler = ngx_http_log_error; | 181 c->log->handler = ngx_http_log_error; |
218 | 218 |
219 static void | 219 static void |
220 ngx_http_init_request(ngx_event_t *rev) | 220 ngx_http_init_request(ngx_event_t *rev) |
221 { | 221 { |
222 ngx_time_t *tp; | 222 ngx_time_t *tp; |
223 socklen_t len; | |
224 ngx_uint_t i; | 223 ngx_uint_t i; |
225 struct sockaddr_in sin; | |
226 ngx_connection_t *c; | 224 ngx_connection_t *c; |
227 ngx_http_request_t *r; | 225 ngx_http_request_t *r; |
228 ngx_http_in_port_t *hip; | 226 ngx_http_in_port_t *hip; |
229 ngx_http_in_addr_t *hia; | 227 ngx_http_in_addr_t *hia; |
230 ngx_http_log_ctx_t *ctx; | 228 ngx_http_log_ctx_t *ctx; |
293 r->port = hip->port; | 291 r->port = hip->port; |
294 r->port_text = &hip->port_text; | 292 r->port_text = &hip->port_text; |
295 | 293 |
296 i = 0; | 294 i = 0; |
297 | 295 |
296 r->connection = c; | |
297 | |
298 if (hip->naddrs > 1) { | 298 if (hip->naddrs > 1) { |
299 | 299 |
300 /* | 300 /* |
301 * There are several addresses on this port and one of them | 301 * There are several addresses on this port and one of them |
302 * is the "*:port" wildcard so getsockname() is needed to determine | 302 * is the "*:port" wildcard so getsockname() is needed to determine |
303 * the server address. | 303 * the server address. |
304 * | 304 * |
305 * AcceptEx() already gave this address. | 305 * AcceptEx() already has given this address. |
306 */ | 306 */ |
307 | 307 |
308 #if (NGX_WIN32) | 308 #if (NGX_WIN32) |
309 if (c->local_sockaddr) { | 309 if (c->local_sockaddr) { |
310 r->in_addr = | 310 r->in_addr = |
311 ((struct sockaddr_in *) c->local_sockaddr)->sin_addr.s_addr; | 311 ((struct sockaddr_in *) c->local_sockaddr)->sin_addr.s_addr; |
312 | 312 |
313 } else | 313 } else |
314 #endif | 314 #endif |
315 { | 315 { |
316 len = sizeof(struct sockaddr_in); | 316 if (ngx_http_server_addr(r, NULL) != NGX_OK) { |
317 if (getsockname(c->fd, (struct sockaddr *) &sin, &len) == -1) { | |
318 ngx_connection_error(c, ngx_socket_errno, | |
319 "getsockname() failed"); | |
320 ngx_http_close_connection(c); | 317 ngx_http_close_connection(c); |
321 return; | 318 return; |
322 } | 319 } |
323 | |
324 r->in_addr = sin.sin_addr.s_addr; | |
325 } | 320 } |
326 | 321 |
327 /* the last address is "*" */ | 322 /* the last address is "*" */ |
328 | 323 |
329 for ( /* void */ ; i < hip->naddrs - 1; i++) { | 324 for ( /* void */ ; i < hip->naddrs - 1; i++) { |
342 cscf = hia[i].core_srv_conf; | 337 cscf = hia[i].core_srv_conf; |
343 | 338 |
344 r->main_conf = cscf->ctx->main_conf; | 339 r->main_conf = cscf->ctx->main_conf; |
345 r->srv_conf = cscf->ctx->srv_conf; | 340 r->srv_conf = cscf->ctx->srv_conf; |
346 r->loc_conf = cscf->ctx->loc_conf; | 341 r->loc_conf = cscf->ctx->loc_conf; |
347 | |
348 r->server_name = cscf->server_name; | |
349 | 342 |
350 rev->handler = ngx_http_process_request_line; | 343 rev->handler = ngx_http_process_request_line; |
351 | 344 |
352 #if (NGX_HTTP_SSL) | 345 #if (NGX_HTTP_SSL) |
353 | 346 |
424 } | 417 } |
425 | 418 |
426 c->single_connection = 1; | 419 c->single_connection = 1; |
427 c->destroyed = 0; | 420 c->destroyed = 0; |
428 | 421 |
429 r->connection = c; | |
430 | |
431 r->main = r; | 422 r->main = r; |
432 | 423 |
433 tp = ngx_timeofday(); | 424 tp = ngx_timeofday(); |
434 r->start_sec = tp->sec; | 425 r->start_sec = tp->sec; |
435 r->start_msec = tp->msec; | 426 r->start_msec = tp->msec; |
497 "https ssl handshake: 0x%02Xd", buf[0]); | 488 "https ssl handshake: 0x%02Xd", buf[0]); |
498 | 489 |
499 rc = ngx_ssl_handshake(c); | 490 rc = ngx_ssl_handshake(c); |
500 | 491 |
501 if (rc == NGX_AGAIN) { | 492 if (rc == NGX_AGAIN) { |
493 | |
494 if (!rev->timer_set) { | |
495 ngx_add_timer(rev, c->listening->post_accept_timeout); | |
496 } | |
497 | |
502 c->ssl->handler = ngx_http_ssl_handshake_handler; | 498 c->ssl->handler = ngx_http_ssl_handshake_handler; |
503 return; | 499 return; |
504 } | 500 } |
505 | 501 |
506 ngx_http_ssl_handshake_handler(c); | 502 ngx_http_ssl_handshake_handler(c); |
1316 | 1312 |
1317 if (r->method & (NGX_HTTP_POST|NGX_HTTP_PUT) | 1313 if (r->method & (NGX_HTTP_POST|NGX_HTTP_PUT) |
1318 && r->headers_in.content_length_n == -1) | 1314 && r->headers_in.content_length_n == -1) |
1319 { | 1315 { |
1320 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, | 1316 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
1321 "client sent POST method without \"Content-Length\" header"); | 1317 "client sent %V method without \"Content-Length\" header", |
1318 &r->method_name); | |
1322 ngx_http_finalize_request(r, NGX_HTTP_LENGTH_REQUIRED); | 1319 ngx_http_finalize_request(r, NGX_HTTP_LENGTH_REQUIRED); |
1323 return NGX_ERROR; | 1320 return NGX_ERROR; |
1324 } | 1321 } |
1325 | 1322 |
1326 if (r->method & NGX_HTTP_TRACE) { | 1323 if (r->method & NGX_HTTP_TRACE) { |
1513 } | 1510 } |
1514 } | 1511 } |
1515 | 1512 |
1516 #endif | 1513 #endif |
1517 | 1514 |
1518 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); | |
1519 | |
1520 if (cscf->wildcard) { | |
1521 r->server_name.len = len; | |
1522 r->server_name.data = host; | |
1523 } | |
1524 | |
1525 return; | 1515 return; |
1526 | 1516 |
1527 found: | 1517 found: |
1528 | |
1529 r->server_name.len = len; | |
1530 r->server_name.data = host; | |
1531 | 1518 |
1532 r->srv_conf = cscf->ctx->srv_conf; | 1519 r->srv_conf = cscf->ctx->srv_conf; |
1533 r->loc_conf = cscf->ctx->loc_conf; | 1520 r->loc_conf = cscf->ctx->loc_conf; |
1534 | 1521 |
1535 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); | 1522 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); |
2596 buf = p; | 2583 buf = p; |
2597 } | 2584 } |
2598 | 2585 |
2599 ctx = log->data; | 2586 ctx = log->data; |
2600 | 2587 |
2601 p = ngx_snprintf(buf, len, ", client: %V", ctx->client); | 2588 p = ngx_snprintf(buf, len, ", client: %V", &ctx->connection->addr_text); |
2602 len -= p - buf; | 2589 len -= p - buf; |
2603 | 2590 |
2604 r = ctx->request; | 2591 r = ctx->request; |
2605 | 2592 |
2606 if (r) { | 2593 if (r) { |
2607 return r->log_handler(r, ctx->current_request, p, len); | 2594 return r->log_handler(r, ctx->current_request, p, len); |
2595 | |
2596 } else { | |
2597 p = ngx_snprintf(p, len, ", server: %V", | |
2598 &ctx->connection->listening->addr_text); | |
2608 } | 2599 } |
2609 | 2600 |
2610 return p; | 2601 return p; |
2611 } | 2602 } |
2612 | 2603 |
2613 | 2604 |
2614 static u_char * | 2605 static u_char * |
2615 ngx_http_log_error_handler(ngx_http_request_t *r, ngx_http_request_t *sr, | 2606 ngx_http_log_error_handler(ngx_http_request_t *r, ngx_http_request_t *sr, |
2616 u_char *buf, size_t len) | 2607 u_char *buf, size_t len) |
2617 { | 2608 { |
2618 char *uri_separator; | 2609 char *uri_separator; |
2619 u_char *p; | 2610 u_char *p; |
2620 ngx_http_upstream_t *u; | 2611 ngx_http_upstream_t *u; |
2621 | 2612 ngx_http_core_srv_conf_t *cscf; |
2622 if (r->server_name.data) { | 2613 |
2623 p = ngx_snprintf(buf, len, ", server: %V", &r->server_name); | 2614 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); |
2624 len -= p - buf; | 2615 |
2625 buf = p; | 2616 p = ngx_snprintf(buf, len, ", server: %V", &cscf->server_name); |
2626 } | 2617 len -= p - buf; |
2618 buf = p; | |
2627 | 2619 |
2628 if (r->request_line.data == NULL && r->request_start) { | 2620 if (r->request_line.data == NULL && r->request_start) { |
2629 for (p = r->request_start; p < r->header_in->last; p++) { | 2621 for (p = r->request_start; p < r->header_in->last; p++) { |
2630 if (*p == CR || *p == LF) { | 2622 if (*p == CR || *p == LF) { |
2631 break; | 2623 break; |