* This routine gets called at two different points in request processing: * once before the URI has been translated (during the post-read-request * phase) and once after (during the header-parse phase). We use different * config records for the two different calls to reduce overhead (by not * re-doing the server-wide settings during directory processing), and * signal which call it is by hav
| 490 | * later one. |
| 491 | */ |
| 492 | static int match_headers(request_rec *r) |
| 493 | { |
| 494 | sei_cfg_rec *sconf; |
| 495 | sei_entry *entries; |
| 496 | const apr_table_entry_t *elts; |
| 497 | const char *val, *err; |
| 498 | apr_size_t val_len = 0; |
| 499 | int i, j; |
| 500 | char *last_name; |
| 501 | ap_regmatch_t regm[AP_MAX_REG_MATCH]; |
| 502 | |
| 503 | if (!ap_get_module_config(r->request_config, &setenvif_module)) { |
| 504 | ap_set_module_config(r->request_config, &setenvif_module, |
| 505 | SEI_MAGIC_HEIRLOOM); |
| 506 | sconf = (sei_cfg_rec *) ap_get_module_config(r->server->module_config, |
| 507 | &setenvif_module); |
| 508 | } |
| 509 | else { |
| 510 | sconf = (sei_cfg_rec *) ap_get_module_config(r->per_dir_config, |
| 511 | &setenvif_module); |
| 512 | } |
| 513 | entries = (sei_entry *) sconf->conditionals->elts; |
| 514 | last_name = NULL; |
| 515 | val = NULL; |
| 516 | for (i = 0; i < sconf->conditionals->nelts; ++i) { |
| 517 | sei_entry *b = &entries[i]; |
| 518 | |
| 519 | if (!b->expr) { |
| 520 | /* Optimize the case where a bunch of directives in a row use the |
| 521 | * same header. Remember we don't need to strcmp the two header |
| 522 | * names because we made sure the pointers were equal during |
| 523 | * configuration. |
| 524 | */ |
| 525 | if (b->name != last_name) { |
| 526 | last_name = b->name; |
| 527 | switch (b->special_type) { |
| 528 | case SPECIAL_REMOTE_ADDR: |
| 529 | val = r->useragent_ip; |
| 530 | break; |
| 531 | case SPECIAL_SERVER_ADDR: |
| 532 | val = r->connection->local_ip; |
| 533 | break; |
| 534 | case SPECIAL_REMOTE_HOST: |
| 535 | val = ap_get_useragent_host(r, REMOTE_NAME, NULL); |
| 536 | break; |
| 537 | case SPECIAL_REQUEST_URI: |
| 538 | val = r->uri; |
| 539 | break; |
| 540 | case SPECIAL_REQUEST_METHOD: |
| 541 | val = r->method; |
| 542 | break; |
| 543 | case SPECIAL_REQUEST_PROTOCOL: |
| 544 | val = r->protocol; |
| 545 | break; |
| 546 | case SPECIAL_NOT: |
| 547 | if (b->pnamereg) { |
| 548 | /* Matching headers_in against a regex. Iterate through |
| 549 | * the headers_in until we find a match or run out of |
nothing calls this directly
no test coverage detected