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

Function proxy_trans

modules/proxy/mod_proxy.c:979–1047  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

977}
978
979static int proxy_trans(request_rec *r, int pre_trans)
980{
981 int i, enc;
982 struct proxy_alias *ent;
983 proxy_dir_conf *dconf;
984 proxy_server_conf *conf;
985
986 if (r->proxyreq) {
987 /* someone has already set up the proxy, it was possibly ourselves
988 * in proxy_detect (DONE will prevent further decoding of r->uri,
989 * only if proxyreq is set before pre_trans already).
990 */
991 return pre_trans ? DONE : OK;
992 }
993
994 /* In early pre_trans hook, r->uri was not manipulated yet so we are
995 * compliant with RFC1945 at this point. Otherwise, it probably isn't
996 * an issue because this is a hybrid proxy/origin server.
997 */
998
999 dconf = ap_get_module_config(r->per_dir_config, &proxy_module);
1000 conf = (proxy_server_conf *) ap_get_module_config(r->server->module_config,
1001 &proxy_module);
1002
1003 /* Always and only do PROXY_MAP_ENCODED mapping in pre_trans, when
1004 * r->uri is still encoded, or we might consider for instance that
1005 * a decoded sub-delim is now a delimiter (e.g. "%3B" => ';' for
1006 * path parameters), which it's not.
1007 */
1008 if ((pre_trans && !conf->map_encoded_one)
1009 || (!pre_trans && conf->map_encoded_all)) {
1010 /* Fast path, nothing at this stage */
1011 return DECLINED;
1012 }
1013
1014 if ((r->unparsed_uri[0] == '*' && r->unparsed_uri[1] == '\0')
1015 || !r->uri || r->uri[0] != '/') {
1016 return DECLINED;
1017 }
1018
1019 if (apr_table_get(r->subprocess_env, "no-proxy")) {
1020 return DECLINED;
1021 }
1022
1023 /* short way - this location is reverse proxied? */
1024 if (dconf->alias) {
1025 enc = (dconf->alias->flags & PROXYPASS_MAP_ENCODED) != 0;
1026 if (!(pre_trans ^ enc)) {
1027 int rv = ap_proxy_trans_match(r, dconf->alias, dconf);
1028 if (rv != HTTP_CONTINUE) {
1029 return rv;
1030 }
1031 }
1032 }
1033
1034 /* long way - walk the list of aliases, find a match */
1035 for (i = 0; i < conf->aliases->nelts; i++) {
1036 ent = &((struct proxy_alias *)conf->aliases->elts)[i];

Callers 2

proxy_pre_translate_nameFunction · 0.85
proxy_translate_nameFunction · 0.85

Calls 2

ap_get_module_configFunction · 0.85
ap_proxy_trans_matchFunction · 0.85

Tested by

no test coverage detected