Mercurial > hg > nginx-vendor-1-0
comparison src/http/ngx_http_request.c @ 448:76a79816b771 NGINX_0_7_36
nginx 0.7.36
*) Feature: a preliminary IPv6 support; the "listen" directive of the
HTTP module supports IPv6.
*) Bugfix: the $ancient_browser variable did not work for browsers
preset by a "modern_browser" directives.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Sat, 21 Feb 2009 00:00:00 +0300 |
parents | 670af56a1158 |
children | a8424ffa495c |
comparison
equal
deleted
inserted
replaced
447:40964c811e59 | 448:76a79816b771 |
---|---|
230 { | 230 { |
231 ngx_time_t *tp; | 231 ngx_time_t *tp; |
232 ngx_uint_t i; | 232 ngx_uint_t i; |
233 ngx_connection_t *c; | 233 ngx_connection_t *c; |
234 ngx_http_request_t *r; | 234 ngx_http_request_t *r; |
235 ngx_http_in_port_t *hip; | 235 struct sockaddr_in *sin; |
236 ngx_http_in_addr_t *hia; | 236 ngx_http_port_t *port; |
237 ngx_http_in_addr_t *addr; | |
237 ngx_http_log_ctx_t *ctx; | 238 ngx_http_log_ctx_t *ctx; |
239 ngx_http_addr_conf_t *addr_conf; | |
238 ngx_http_connection_t *hc; | 240 ngx_http_connection_t *hc; |
239 ngx_http_core_srv_conf_t *cscf; | 241 ngx_http_core_srv_conf_t *cscf; |
240 ngx_http_core_loc_conf_t *clcf; | 242 ngx_http_core_loc_conf_t *clcf; |
241 ngx_http_core_main_conf_t *cmcf; | 243 ngx_http_core_main_conf_t *cmcf; |
244 #if (NGX_HAVE_INET6) | |
245 struct sockaddr_in6 *sin6; | |
246 ngx_http_in6_addr_t *addr6; | |
247 #endif | |
242 | 248 |
243 #if (NGX_STAT_STUB) | 249 #if (NGX_STAT_STUB) |
244 ngx_atomic_fetch_add(ngx_stat_reading, -1); | 250 ngx_atomic_fetch_add(ngx_stat_reading, -1); |
245 #endif | 251 #endif |
246 | 252 |
290 c->sent = 0; | 296 c->sent = 0; |
291 r->signature = NGX_HTTP_MODULE; | 297 r->signature = NGX_HTTP_MODULE; |
292 | 298 |
293 /* find the server configuration for the address:port */ | 299 /* find the server configuration for the address:port */ |
294 | 300 |
295 /* AF_INET only */ | 301 port = c->listening->servers; |
296 | 302 |
297 hip = c->listening->servers; | 303 r->port = port->port; |
298 hia = hip->addrs; | 304 r->port_text = &port->port_text; |
299 | |
300 r->port = hip->port; | |
301 r->port_text = &hip->port_text; | |
302 | |
303 i = 0; | |
304 | 305 |
305 r->connection = c; | 306 r->connection = c; |
306 | 307 |
307 if (hip->naddrs > 1) { | 308 if (port->naddrs > 1) { |
308 | 309 |
309 /* | 310 /* |
310 * There are several addresses on this port and one of them | 311 * there are several addresses on this port and one of them |
311 * is the "*:port" wildcard so getsockname() is needed to determine | 312 * is an "*:port" wildcard so getsockname() in ngx_http_server_addr() |
312 * the server address. | 313 * is required to determine a server address |
313 * | |
314 * AcceptEx() already has given this address. | |
315 */ | 314 */ |
316 | 315 |
317 #if (NGX_WIN32) | 316 c->local_sockaddr = NULL; |
318 if (c->local_sockaddr) { | 317 |
319 r->in_addr = | 318 if (ngx_http_server_addr(r, NULL) != NGX_OK) { |
320 ((struct sockaddr_in *) c->local_sockaddr)->sin_addr.s_addr; | 319 ngx_http_close_connection(c); |
321 | 320 return; |
322 } else | 321 } |
323 #endif | 322 |
324 { | 323 switch (c->local_sockaddr->sa_family) { |
325 if (ngx_http_server_addr(r, NULL) != NGX_OK) { | 324 |
326 ngx_http_close_connection(c); | 325 #if (NGX_HAVE_INET6) |
327 return; | 326 case AF_INET6: |
328 } | 327 sin6 = (struct sockaddr_in6 *) c->local_sockaddr; |
329 } | 328 |
330 | 329 addr6 = (ngx_http_in6_addr_t *) port->addrs; |
331 /* the last address is "*" */ | 330 |
332 | 331 /* the last address is "*" */ |
333 for ( /* void */ ; i < hip->naddrs - 1; i++) { | 332 |
334 if (hia[i].addr == r->in_addr) { | 333 for (i = 0; i < port->naddrs - 1; i++) { |
335 break; | 334 if (ngx_memcmp(&addr6[i].addr6, &sin6->sin6_addr, 16) == 0) { |
336 } | 335 break; |
336 } | |
337 } | |
338 | |
339 addr_conf = &addr6[i].conf; | |
340 | |
341 break; | |
342 #endif | |
343 | |
344 default: /* AF_INET */ | |
345 sin = (struct sockaddr_in *) c->local_sockaddr; | |
346 | |
347 addr = port->addrs; | |
348 | |
349 /* the last address is "*" */ | |
350 | |
351 for (i = 0; i < port->naddrs - 1; i++) { | |
352 if (addr[i].addr == sin->sin_addr.s_addr) { | |
353 break; | |
354 } | |
355 } | |
356 | |
357 addr_conf = &addr[i].conf; | |
358 | |
359 break; | |
337 } | 360 } |
338 | 361 |
339 } else { | 362 } else { |
340 r->in_addr = hia[0].addr; | 363 |
341 } | 364 switch (c->local_sockaddr->sa_family) { |
342 | 365 |
343 r->virtual_names = hia[i].virtual_names; | 366 #if (NGX_HAVE_INET6) |
367 case AF_INET6: | |
368 addr6 = (ngx_http_in6_addr_t *) port->addrs; | |
369 addr_conf = &addr6[0].conf; | |
370 break; | |
371 #endif | |
372 | |
373 default: /* AF_INET */ | |
374 addr = port->addrs; | |
375 addr_conf = &addr[0].conf; | |
376 r->in_addr = addr[0].addr; | |
377 break; | |
378 } | |
379 } | |
380 | |
381 r->virtual_names = addr_conf->virtual_names; | |
344 | 382 |
345 /* the default server configuration for the address:port */ | 383 /* the default server configuration for the address:port */ |
346 cscf = hia[i].core_srv_conf; | 384 cscf = addr_conf->core_srv_conf; |
347 | 385 |
348 r->main_conf = cscf->ctx->main_conf; | 386 r->main_conf = cscf->ctx->main_conf; |
349 r->srv_conf = cscf->ctx->srv_conf; | 387 r->srv_conf = cscf->ctx->srv_conf; |
350 r->loc_conf = cscf->ctx->loc_conf; | 388 r->loc_conf = cscf->ctx->loc_conf; |
351 | 389 |
355 | 393 |
356 { | 394 { |
357 ngx_http_ssl_srv_conf_t *sscf; | 395 ngx_http_ssl_srv_conf_t *sscf; |
358 | 396 |
359 sscf = ngx_http_get_module_srv_conf(r, ngx_http_ssl_module); | 397 sscf = ngx_http_get_module_srv_conf(r, ngx_http_ssl_module); |
360 if (sscf->enable || hia[i].ssl) { | 398 if (sscf->enable || addr_conf->ssl) { |
361 | 399 |
362 if (c->ssl == NULL) { | 400 if (c->ssl == NULL) { |
363 | 401 |
364 c->log->action = "SSL handshaking"; | 402 c->log->action = "SSL handshaking"; |
365 | 403 |
366 if (hia[i].ssl && sscf->ssl.ctx == NULL) { | 404 if (addr_conf->ssl && sscf->ssl.ctx == NULL) { |
367 ngx_log_error(NGX_LOG_ERR, c->log, 0, | 405 ngx_log_error(NGX_LOG_ERR, c->log, 0, |
368 "no \"ssl_certificate\" is defined " | 406 "no \"ssl_certificate\" is defined " |
369 "in server listening on SSL port"); | 407 "in server listening on SSL port"); |
370 ngx_http_close_connection(c); | 408 ngx_http_close_connection(c); |
371 return; | 409 return; |