| 1211 | /* Invoke handler */ |
| 1212 | |
| 1213 | static int proxy_handler(request_rec *r) |
| 1214 | { |
| 1215 | char *uri, *scheme, *p; |
| 1216 | const char *p2; |
| 1217 | void *sconf = r->server->module_config; |
| 1218 | proxy_server_conf *conf = (proxy_server_conf *) |
| 1219 | ap_get_module_config(sconf, &proxy_module); |
| 1220 | apr_array_header_t *proxies = conf->proxies; |
| 1221 | struct proxy_remote *ents = (struct proxy_remote *) proxies->elts; |
| 1222 | int rc = DECLINED, access_status, i; |
| 1223 | int direct_connect = 0; |
| 1224 | const char *str; |
| 1225 | apr_int64_t maxfwd; |
| 1226 | proxy_balancer *balancer = NULL; |
| 1227 | proxy_worker *worker = NULL; |
| 1228 | int attempts = 0, max_attempts = 0; |
| 1229 | struct dirconn_entry *list = (struct dirconn_entry *)conf->dirconn->elts; |
| 1230 | int saved_status; |
| 1231 | |
| 1232 | /* is this for us? */ |
| 1233 | if (!r->filename) { |
| 1234 | return DECLINED; |
| 1235 | } |
| 1236 | |
| 1237 | /* We may have forced the proxy handler via config or .htaccess */ |
| 1238 | if (!r->proxyreq && r->handler && strncmp(r->handler, "proxy:", 6) == 0) { |
| 1239 | char *old_filename = r->filename; |
| 1240 | |
| 1241 | r->proxyreq = PROXYREQ_REVERSE; |
| 1242 | r->filename = apr_pstrcat(r->pool, r->handler, r->filename, NULL); |
| 1243 | apr_table_setn(r->notes, "proxy-sethandler", "1"); |
| 1244 | |
| 1245 | /* Still need to canonicalize r->filename */ |
| 1246 | rc = ap_proxy_canon_url(r); |
| 1247 | if (rc != OK) { |
| 1248 | r->filename = old_filename; |
| 1249 | r->proxyreq = 0; |
| 1250 | } |
| 1251 | } |
| 1252 | else if (r->proxyreq && strncmp(r->filename, "proxy:", 6) == 0) { |
| 1253 | apr_table_unset(r->notes, "proxy-sethandler"); |
| 1254 | rc = OK; |
| 1255 | } |
| 1256 | if (rc != OK) { |
| 1257 | return rc; |
| 1258 | } |
| 1259 | |
| 1260 | uri = r->filename + 6; |
| 1261 | p = strchr(uri, ':'); |
| 1262 | if (p == NULL) { |
| 1263 | ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01141) |
| 1264 | "proxy_handler no URL in %s", r->filename); |
| 1265 | return HTTP_BAD_REQUEST; |
| 1266 | } |
| 1267 | scheme = apr_pstrmemdup(r->pool, uri, p - uri); |
| 1268 | |
| 1269 | /* handle max-forwards / OPTIONS / TRACE */ |
| 1270 | if ((str = apr_table_get(r->headers_in, "Max-Forwards"))) { |
nothing calls this directly
no test coverage detected