comparison src/http/ngx_http_request.c @ 1387:cb8b30ef3e7e

regex in server_name
author Igor Sysoev <igor@sysoev.ru>
date Sun, 12 Aug 2007 19:48:12 +0000
parents fdea12ffb24a
children 75e908236701
comparison
equal deleted inserted replaced
1386:3c6da0610f19 1387:cb8b30ef3e7e
1451 1451
1452 static void 1452 static void
1453 ngx_http_find_virtual_server(ngx_http_request_t *r, u_char *host, size_t len, 1453 ngx_http_find_virtual_server(ngx_http_request_t *r, u_char *host, size_t len,
1454 ngx_uint_t hash) 1454 ngx_uint_t hash)
1455 { 1455 {
1456 ngx_http_virtual_names_t *vn;
1457 ngx_http_core_loc_conf_t *clcf; 1456 ngx_http_core_loc_conf_t *clcf;
1458 ngx_http_core_srv_conf_t *cscf; 1457 ngx_http_core_srv_conf_t *cscf;
1459 1458 #if (NGX_PCRE)
1460 vn = r->virtual_names; 1459 ngx_int_t n;
1461 1460 ngx_uint_t i;
1462 cscf = ngx_hash_find_combined(vn, hash, host, len); 1461 ngx_str_t name;
1462 ngx_http_server_name_t *sn;
1463 #endif
1464
1465 cscf = ngx_hash_find_combined(&r->virtual_names->names, hash, host, len);
1463 1466
1464 if (cscf) { 1467 if (cscf) {
1465 goto found; 1468 goto found;
1466 } 1469 }
1470
1471 #if (NGX_PCRE)
1472
1473 if (r->virtual_names->nregex) {
1474
1475 name.len = len;
1476 name.data = host;
1477
1478 sn = r->virtual_names->regex;
1479
1480 for (i = 0; i < r->virtual_names->nregex; i++) {
1481
1482 n = ngx_regex_exec(sn[i].regex, &name, NULL, 0);
1483
1484 if (n == NGX_REGEX_NO_MATCHED) {
1485 continue;
1486 }
1487
1488 if (n < 0) {
1489 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
1490 ngx_regex_exec_n
1491 " failed: %d on \"%V\" using \"%V\"",
1492 n, &name, &sn[i].name);
1493 return;
1494 }
1495
1496 /* match */
1497
1498 cscf = sn[i].core_srv_conf;
1499
1500 goto found;
1501 }
1502 }
1503
1504 #endif
1467 1505
1468 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); 1506 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);
1469 1507
1470 if (cscf->wildcard) { 1508 if (cscf->wildcard) {
1471 r->server_name.len = len; 1509 r->server_name.len = len;