MCPcopy Create free account
hub / github.com/apache/httpd / proxy_detect

Function proxy_detect

modules/proxy/mod_proxy.c:791–823  ·  view source on GitHub ↗

Detect if an absoluteURI should be proxied or not. Note that we * have to do this during this phase because later phases are * "short-circuiting"... i.e. translate_names will end when the first * module returns OK. So for example, if the request is something like: * * GET http://othervhost/cgi-bin/printenv HTTP/1.0 * * mod_alias will notice the /cgi-bin part and ScriptAlias it and * shor

Source from the content-addressed store, hash-verified

789 * configuration file.
790 */
791static int proxy_detect(request_rec *r)
792{
793 void *sconf = r->server->module_config;
794 proxy_server_conf *conf =
795 (proxy_server_conf *) ap_get_module_config(sconf, &proxy_module);
796
797 /* Ick... msvc (perhaps others) promotes ternary short results to int */
798
799 if (conf->req && r->parsed_uri.scheme) {
800 /* but it might be something vhosted */
801 if (!r->parsed_uri.hostname
802 || ap_cstr_casecmp(r->parsed_uri.scheme, ap_http_scheme(r)) != 0
803 || !ap_matches_request_vhost(r, r->parsed_uri.hostname,
804 (apr_port_t)(r->parsed_uri.port_str
805 ? r->parsed_uri.port
806 : ap_default_port(r)))) {
807 r->proxyreq = PROXYREQ_PROXY;
808 r->uri = r->unparsed_uri;
809 r->filename = apr_pstrcat(r->pool, "proxy:", r->uri, NULL);
810 r->handler = "proxy-server";
811 }
812 }
813 /* We need special treatment for CONNECT proxying: it has no scheme part */
814 else if (conf->req && r->method_number == M_CONNECT
815 && r->parsed_uri.hostname
816 && r->parsed_uri.port_str) {
817 r->proxyreq = PROXYREQ_PROXY;
818 r->uri = r->unparsed_uri;
819 r->filename = apr_pstrcat(r->pool, "proxy:", r->uri, NULL);
820 r->handler = "proxy-server";
821 }
822 return DECLINED;
823}
824
825PROXY_DECLARE(int) ap_proxy_trans_match(request_rec *r, struct proxy_alias *ent,
826 proxy_dir_conf *dconf)

Callers

nothing calls this directly

Calls 3

ap_get_module_configFunction · 0.85
ap_cstr_casecmpFunction · 0.85
ap_matches_request_vhostFunction · 0.85

Tested by

no test coverage detected