* This handles http:// URLs, and other URLs using a remote proxy over http * If proxyhost is NULL, then contact the server directly, otherwise * go via the proxy. * Note that if a proxy is used, then URLs other than http: can be accessed, * also, if we have trouble which is clearly specific to the proxy, then * we return DECLINED so that we can try another proxy. (Or the direct * route.) */
| 1868 | * route.) |
| 1869 | */ |
| 1870 | static int proxy_http_handler(request_rec *r, proxy_worker *worker, |
| 1871 | proxy_server_conf *conf, |
| 1872 | char *url, const char *proxyname, |
| 1873 | apr_port_t proxyport) |
| 1874 | { |
| 1875 | int status; |
| 1876 | const char *scheme; |
| 1877 | const char *u = url; |
| 1878 | proxy_http_req_t *req = NULL; |
| 1879 | proxy_conn_rec *backend = NULL; |
| 1880 | apr_bucket_brigade *input_brigade = NULL; |
| 1881 | int is_ssl = 0; |
| 1882 | conn_rec *c = r->connection; |
| 1883 | proxy_dir_conf *dconf; |
| 1884 | int retry = 0; |
| 1885 | char *locurl = url; |
| 1886 | int toclose = 0; |
| 1887 | /* |
| 1888 | * Use a shorter-lived pool to reduce memory usage |
| 1889 | * and avoid a memory leak |
| 1890 | */ |
| 1891 | apr_pool_t *p = r->pool; |
| 1892 | apr_uri_t *uri; |
| 1893 | |
| 1894 | scheme = get_url_scheme(&u, &is_ssl); |
| 1895 | if (!scheme && proxyname && strncasecmp(url, "ftp:", 4) == 0) { |
| 1896 | u = url + 4; |
| 1897 | scheme = "ftp"; |
| 1898 | is_ssl = 0; |
| 1899 | } |
| 1900 | if (!scheme || u[0] != '/' || u[1] != '/' || u[2] == '\0') { |
| 1901 | ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01113) |
| 1902 | "HTTP: declining URL %s", url); |
| 1903 | return DECLINED; /* only interested in HTTP, WS or FTP via proxy */ |
| 1904 | } |
| 1905 | if (is_ssl && !ap_ssl_has_outgoing_handlers()) { |
| 1906 | ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01112) |
| 1907 | "HTTP: declining URL %s (mod_ssl not configured?)", url); |
| 1908 | return DECLINED; |
| 1909 | } |
| 1910 | ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, "HTTP: serving URL %s", url); |
| 1911 | |
| 1912 | /* create space for state information */ |
| 1913 | if ((status = ap_proxy_acquire_connection(scheme, &backend, |
| 1914 | worker, r->server)) != OK) { |
| 1915 | return status; |
| 1916 | } |
| 1917 | |
| 1918 | backend->is_ssl = is_ssl; |
| 1919 | |
| 1920 | req = apr_pcalloc(p, sizeof(*req)); |
| 1921 | req->p = p; |
| 1922 | req->r = r; |
| 1923 | req->sconf = conf; |
| 1924 | req->worker = worker; |
| 1925 | req->backend = backend; |
| 1926 | req->proto = scheme; |
| 1927 | req->bucket_alloc = c->bucket_alloc; |
nothing calls this directly
no test coverage detected