| 426 | } |
| 427 | |
| 428 | static apr_status_t cache_canonicalise_key(request_rec *r, apr_pool_t* p, |
| 429 | const char *path, const char *query, |
| 430 | apr_uri_t *parsed_uri, |
| 431 | const char **key) |
| 432 | { |
| 433 | cache_server_conf *conf; |
| 434 | char *port_str, *hn, *lcs; |
| 435 | const char *hostname, *scheme; |
| 436 | int i; |
| 437 | const char *kpath; |
| 438 | const char *kquery; |
| 439 | |
| 440 | if (*key) { |
| 441 | /* |
| 442 | * We have been here before during the processing of this request. |
| 443 | */ |
| 444 | return APR_SUCCESS; |
| 445 | } |
| 446 | |
| 447 | /* |
| 448 | * Get the module configuration. We need this for the CacheIgnoreQueryString |
| 449 | * option below. |
| 450 | */ |
| 451 | conf = (cache_server_conf *) ap_get_module_config(r->server->module_config, |
| 452 | &cache_module); |
| 453 | |
| 454 | /* |
| 455 | * Use the canonical name to improve cache hit rate, but only if this is |
| 456 | * not a proxy request or if this is a reverse proxy request. |
| 457 | * We need to handle both cases in the same manner as for the reverse proxy |
| 458 | * case we have the following situation: |
| 459 | * |
| 460 | * If a cached entry is looked up by mod_cache's quick handler r->proxyreq |
| 461 | * is still unset in the reverse proxy case as it only gets set in the |
| 462 | * translate name hook (either by ProxyPass or mod_rewrite) which is run |
| 463 | * after the quick handler hook. This is different to the forward proxy |
| 464 | * case where it gets set before the quick handler is run (in the |
| 465 | * post_read_request hook). |
| 466 | * If a cache entry is created by the CACHE_SAVE filter we always have |
| 467 | * r->proxyreq set correctly. |
| 468 | * So we must ensure that in the reverse proxy case we use the same code |
| 469 | * path and using the canonical name seems to be the right thing to do |
| 470 | * in the reverse proxy case. |
| 471 | */ |
| 472 | if (!r->proxyreq || (r->proxyreq == PROXYREQ_REVERSE)) { |
| 473 | if (conf->base_uri && conf->base_uri->hostname) { |
| 474 | hostname = conf->base_uri->hostname; |
| 475 | } |
| 476 | else { |
| 477 | /* Use _default_ as the hostname if none present, as in mod_vhost */ |
| 478 | hostname = ap_get_server_name(r); |
| 479 | if (!hostname) { |
| 480 | hostname = "_default_"; |
| 481 | } |
| 482 | } |
| 483 | } |
| 484 | else if (parsed_uri->hostname) { |
| 485 | /* Copy the parsed uri hostname */ |
no test coverage detected