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

Function ap_proxy_location_reverse_map

modules/proxy/proxy_util.c:882–991  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

880}
881
882PROXY_DECLARE(const char *) ap_proxy_location_reverse_map(request_rec *r,
883 proxy_dir_conf *conf, const char *url)
884{
885 proxy_req_conf *rconf;
886 struct proxy_alias *ent;
887 int i, l1, l1_orig, l2;
888 char *u;
889
890 /*
891 * XXX FIXME: Make sure this handled the ambiguous case of the :<PORT>
892 * after the hostname
893 * XXX FIXME: Ensure the /uri component is a case sensitive match
894 */
895 if (r->proxyreq != PROXYREQ_REVERSE) {
896 return url;
897 }
898
899 l1_orig = strlen(url);
900 if (conf->interpolate_env == 1) {
901 rconf = ap_get_module_config(r->request_config, &proxy_module);
902 ent = (struct proxy_alias *)rconf->raliases->elts;
903 }
904 else {
905 ent = (struct proxy_alias *)conf->raliases->elts;
906 }
907 for (i = 0; i < conf->raliases->nelts; i++) {
908 proxy_server_conf *sconf = (proxy_server_conf *)
909 ap_get_module_config(r->server->module_config, &proxy_module);
910 proxy_balancer *balancer;
911 const char *real = ent[i].real;
912
913 /* Restore the url length, if it had been changed by the code below */
914 l1 = l1_orig;
915
916 /*
917 * First check if mapping against a balancer and see
918 * if we have such a entity. If so, then we need to
919 * find the particulars of the actual worker which may
920 * or may not be the right one... basically, we need
921 * to find which member actually handled this request.
922 */
923 if (ap_proxy_valid_balancer_name((char *)real, 0) &&
924 (balancer = ap_proxy_get_balancer(r->pool, sconf, real, 1))) {
925 int n, l3 = 0;
926 proxy_worker **worker = (proxy_worker **)balancer->workers->elts;
927 const char *urlpart = ap_strchr_c(real + sizeof(BALANCER_PREFIX) - 1, '/');
928 if (urlpart) {
929 if (!urlpart[1])
930 urlpart = NULL;
931 else
932 l3 = strlen(urlpart);
933 }
934 /* The balancer comparison is a bit trickier. Given the context
935 * BalancerMember balancer://alias http://example.com/foo
936 * ProxyPassReverse /bash balancer://alias/bar
937 * translate url http://example.com/foo/bar/that to /bash/that
938 */
939 for (n = 0; n < balancer->workers->nelts; n++) {

Callers 2

ajp_unmarshal_responseFunction · 0.85
map_linkFunction · 0.85

Calls 7

ap_get_module_configFunction · 0.85
ap_proxy_get_balancerFunction · 0.85
ap_strchr_cFunction · 0.85
ap_is_urlFunction · 0.85
ap_construct_urlFunction · 0.85
ap_strstr_cFunction · 0.85

Tested by

no test coverage detected