comparison src/http/ngx_http_request.c @ 1618:fbf94b8341bf stable-0.5

r1386, r1388, r1389, r1580, r1581 merge: regex in server_name and valid_referers
author Igor Sysoev <igor@sysoev.ru>
date Wed, 07 Nov 2007 13:46:29 +0000
parents cacb565c554e
children 3b7262e720c1
comparison
equal deleted inserted replaced
1617:cacb565c554e 1618:fbf94b8341bf
1455 1455
1456 static void 1456 static void
1457 ngx_http_find_virtual_server(ngx_http_request_t *r, u_char *host, size_t len, 1457 ngx_http_find_virtual_server(ngx_http_request_t *r, u_char *host, size_t len,
1458 ngx_uint_t hash) 1458 ngx_uint_t hash)
1459 { 1459 {
1460 ngx_http_virtual_names_t *vn;
1461 ngx_http_core_loc_conf_t *clcf; 1460 ngx_http_core_loc_conf_t *clcf;
1462 ngx_http_core_srv_conf_t *cscf; 1461 ngx_http_core_srv_conf_t *cscf;
1463 1462 #if (NGX_PCRE)
1464 vn = r->virtual_names; 1463 ngx_int_t n;
1465 1464 ngx_uint_t i;
1466 cscf = ngx_hash_find_combined(vn, hash, host, len); 1465 ngx_str_t name;
1466 ngx_http_server_name_t *sn;
1467 #endif
1468
1469 cscf = ngx_hash_find_combined(&r->virtual_names->names, hash, host, len);
1467 1470
1468 if (cscf) { 1471 if (cscf) {
1469 goto found; 1472 goto found;
1470 } 1473 }
1474
1475 #if (NGX_PCRE)
1476
1477 if (r->virtual_names->nregex) {
1478
1479 name.len = len;
1480 name.data = host;
1481
1482 sn = r->virtual_names->regex;
1483
1484 for (i = 0; i < r->virtual_names->nregex; i++) {
1485
1486 n = ngx_regex_exec(sn[i].regex, &name, NULL, 0);
1487
1488 if (n == NGX_REGEX_NO_MATCHED) {
1489 continue;
1490 }
1491
1492 if (n < 0) {
1493 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
1494 ngx_regex_exec_n
1495 " failed: %d on \"%V\" using \"%V\"",
1496 n, &name, &sn[i].name);
1497 return;
1498 }
1499
1500 /* match */
1501
1502 cscf = sn[i].core_srv_conf;
1503
1504 goto found;
1505 }
1506 }
1507
1508 #endif
1471 1509
1472 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); 1510 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);
1473 1511
1474 if (cscf->wildcard) { 1512 if (cscf->wildcard) {
1475 r->server_name.len = len; 1513 r->server_name.len = len;