comparison src/http/ngx_http_request.c @ 478:f2c6a7373274 NGINX_0_7_51

nginx 0.7.51 *) Feature: the "try_files" directive supports a response code in the fallback parameter. *) Feature: now any response code can be used in the "return" directive. *) Bugfix: the "error_page" directive made an external redirect without query string; the bug had appeared in 0.7.44. *) Bugfix: if servers listened on several defined explicitly addresses, then virtual servers might not work; the bug had appeared in 0.7.39.
author Igor Sysoev <http://sysoev.ru>
date Sun, 12 Apr 2009 00:00:00 +0400
parents 09f0ef15d544
children 392c16f2d858
comparison
equal deleted inserted replaced
477:ba2ea8c4d60f 478:f2c6a7373274
370 addr_conf = &addr[0].conf; 370 addr_conf = &addr[0].conf;
371 break; 371 break;
372 } 372 }
373 } 373 }
374 374
375 r->virtual_names = addr_conf->virtual_names;
376
375 /* the default server configuration for the address:port */ 377 /* the default server configuration for the address:port */
376 cscf = addr_conf->core_srv_conf; 378 cscf = addr_conf->core_srv_conf;
377 379
378 r->main_conf = cscf->ctx->main_conf; 380 r->main_conf = cscf->ctx->main_conf;
379 r->srv_conf = cscf->ctx->srv_conf; 381 r->srv_conf = cscf->ctx->srv_conf;
1607 static ngx_int_t 1609 static ngx_int_t
1608 ngx_http_find_virtual_server(ngx_http_request_t *r, u_char *host, size_t len) 1610 ngx_http_find_virtual_server(ngx_http_request_t *r, u_char *host, size_t len)
1609 { 1611 {
1610 u_char *server; 1612 u_char *server;
1611 ngx_uint_t hash; 1613 ngx_uint_t hash;
1612 ngx_http_virtual_names_t *vn;
1613 ngx_http_core_loc_conf_t *clcf; 1614 ngx_http_core_loc_conf_t *clcf;
1614 ngx_http_core_srv_conf_t *cscf; 1615 ngx_http_core_srv_conf_t *cscf;
1615 u_char buf[32]; 1616 u_char buf[32];
1616 1617
1617 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); 1618 if (r->virtual_names == NULL) {
1618 vn = cscf->virtual_names;
1619
1620 if (vn == NULL) {
1621 return NGX_DECLINED; 1619 return NGX_DECLINED;
1622 } 1620 }
1623 1621
1624 if (len <= 32) { 1622 if (len <= 32) {
1625 server = buf; 1623 server = buf;
1631 } 1629 }
1632 } 1630 }
1633 1631
1634 hash = ngx_hash_strlow(server, host, len); 1632 hash = ngx_hash_strlow(server, host, len);
1635 1633
1636 cscf = ngx_hash_find_combined(&vn->names, hash, server, len); 1634 cscf = ngx_hash_find_combined(&r->virtual_names->names, hash, server, len);
1637 1635
1638 if (cscf) { 1636 if (cscf) {
1639 goto found; 1637 goto found;
1640 } 1638 }
1641 1639
1642 #if (NGX_PCRE) 1640 #if (NGX_PCRE)
1643 1641
1644 if (vn->nregex) { 1642 if (r->virtual_names->nregex) {
1645 size_t ncaptures; 1643 size_t ncaptures;
1646 ngx_int_t n; 1644 ngx_int_t n;
1647 ngx_uint_t i; 1645 ngx_uint_t i;
1648 ngx_str_t name; 1646 ngx_str_t name;
1649 ngx_http_server_name_t *sn; 1647 ngx_http_server_name_t *sn;
1651 name.len = len; 1649 name.len = len;
1652 name.data = server; 1650 name.data = server;
1653 1651
1654 ncaptures = 0; 1652 ncaptures = 0;
1655 1653
1656 sn = vn->regex; 1654 sn = r->virtual_names->regex;
1657 1655
1658 for (i = 0; i < vn->nregex; i++) { 1656 for (i = 0; i < r->virtual_names->nregex; i++) {
1659 1657
1660 if (sn[i].captures && r->captures == NULL) { 1658 if (sn[i].captures && r->captures == NULL) {
1661 1659
1662 ncaptures = (NGX_HTTP_MAX_CAPTURES + 1) * 3; 1660 ncaptures = (NGX_HTTP_MAX_CAPTURES + 1) * 3;
1663 1661