Lines 17-22
Link Here
|
17 |
/* HTTP routines for Apache proxy */ |
17 |
/* HTTP routines for Apache proxy */ |
18 |
|
18 |
|
19 |
#include "mod_proxy.h" |
19 |
#include "mod_proxy.h" |
|
|
20 |
#include "proxy_util.h" /* ap_proxy_conn_create() */ |
20 |
#include "ap_regex.h" |
21 |
#include "ap_regex.h" |
21 |
|
22 |
|
22 |
module AP_MODULE_DECLARE_DATA proxy_http_module; |
23 |
module AP_MODULE_DECLARE_DATA proxy_http_module; |
Lines 24-29
module AP_MODULE_DECLARE_DATA proxy_http_module;
Link Here
|
24 |
static int (*ap_proxy_clear_connection_fn)(request_rec *r, apr_table_t *headers) = |
25 |
static int (*ap_proxy_clear_connection_fn)(request_rec *r, apr_table_t *headers) = |
25 |
NULL; |
26 |
NULL; |
26 |
|
27 |
|
|
|
28 |
static int (*ap_proxy_conn_create_fn)(proxy_conn_rec **pconn, |
29 |
proxy_worker *worker, |
30 |
apr_pool_t *pool) = NULL; |
31 |
|
32 |
static int (*ap_proxy_retry_worker_fn)(const char *proxy_function, |
33 |
proxy_worker *worker, |
34 |
server_rec *s) = NULL; |
35 |
|
27 |
static apr_status_t ap_proxy_http_cleanup(const char *scheme, |
36 |
static apr_status_t ap_proxy_http_cleanup(const char *scheme, |
28 |
request_rec *r, |
37 |
request_rec *r, |
29 |
proxy_conn_rec *backend); |
38 |
proxy_conn_rec *backend); |
Lines 1837-1842
apr_status_t ap_proxy_http_cleanup(const char *sch
Link Here
|
1837 |
return OK; |
1846 |
return OK; |
1838 |
} |
1847 |
} |
1839 |
|
1848 |
|
|
|
1849 |
static int proxy_http_acquire_1for1_connection(const char *proxy_function, |
1850 |
proxy_conn_rec **pconn, |
1851 |
proxy_worker *worker, |
1852 |
request_rec *r) |
1853 |
{ |
1854 |
conn_rec *c = r->connection; |
1855 |
server_rec *s = r->server; |
1856 |
proxy_conn_rec *conn; |
1857 |
apr_status_t rv; |
1858 |
|
1859 |
*pconn = NULL; |
1860 |
|
1861 |
if (!PROXY_WORKER_IS_USABLE(worker)) { |
1862 |
/* Retry the worker */ |
1863 |
ap_proxy_retry_worker_fn(proxy_function, worker, s); |
1864 |
|
1865 |
if (!PROXY_WORKER_IS_USABLE(worker)) { |
1866 |
ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, APLOGNO() |
1867 |
"%s: disabled 1for1 connection for (%s)", |
1868 |
proxy_function, worker->s->hostname); |
1869 |
return HTTP_SERVICE_UNAVAILABLE; |
1870 |
} |
1871 |
} |
1872 |
|
1873 |
conn = (proxy_conn_rec *)ap_get_module_config(c->conn_config, |
1874 |
&proxy_http_module); |
1875 |
if (!conn) { |
1876 |
rv = ap_proxy_conn_create_fn(&conn, worker, c->pool); |
1877 |
if (rv != APR_SUCCESS) { |
1878 |
ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, APLOGNO() |
1879 |
"%s: failed to acquire 1for1 connection for (%s)", |
1880 |
proxy_function, worker->s->hostname); |
1881 |
return HTTP_INTERNAL_SERVER_ERROR; |
1882 |
} |
1883 |
|
1884 |
ap_set_module_config(c->conn_config, &proxy_http_module, conn); |
1885 |
} |
1886 |
|
1887 |
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, APLOGNO() |
1888 |
"%s: has acquired 1for1 connection for (%s)", |
1889 |
proxy_function, worker->s->hostname); |
1890 |
*pconn = conn; |
1891 |
|
1892 |
return OK; |
1893 |
} |
1894 |
|
1840 |
/* |
1895 |
/* |
1841 |
* This handles http:// URLs, and other URLs using a remote proxy over http |
1896 |
* This handles http:// URLs, and other URLs using a remote proxy over http |
1842 |
* If proxyhost is NULL, then contact the server directly, otherwise |
1897 |
* If proxyhost is NULL, then contact the server directly, otherwise |
Lines 1902-1910
static int proxy_http_handler(request_rec *r, prox
Link Here
|
1902 |
|
1957 |
|
1903 |
|
1958 |
|
1904 |
/* create space for state information */ |
1959 |
/* create space for state information */ |
1905 |
if ((status = ap_proxy_acquire_connection(proxy_function, &backend, |
1960 |
if (apr_table_get(r->subprocess_env, "proxy-1for1-connection")) { |
1906 |
worker, r->server)) != OK) |
1961 |
status = proxy_http_acquire_1for1_connection(proxy_function, &backend, |
|
|
1962 |
worker, r); |
1963 |
} |
1964 |
else { |
1965 |
status = ap_proxy_acquire_connection(proxy_function, &backend, worker, |
1966 |
r->server); |
1967 |
} |
1968 |
if (status != OK) { |
1907 |
goto cleanup; |
1969 |
goto cleanup; |
|
|
1970 |
} |
1908 |
|
1971 |
|
1909 |
|
1972 |
|
1910 |
backend->is_ssl = is_ssl; |
1973 |
backend->is_ssl = is_ssl; |
Lines 2034-2039
static int proxy_http_post_config(apr_pool_t *pcon
Link Here
|
2034 |
} |
2097 |
} |
2035 |
} |
2098 |
} |
2036 |
|
2099 |
|
|
|
2100 |
if (!ap_proxy_conn_create_fn) { |
2101 |
ap_proxy_conn_create_fn = |
2102 |
APR_RETRIEVE_OPTIONAL_FN(ap_proxy_conn_create); |
2103 |
if (!ap_proxy_conn_create_fn) { |
2104 |
ap_log_error(APLOG_MARK, APLOG_EMERG, 0, s, APLOGNO() |
2105 |
"mod_proxy must be loaded for mod_proxy_http"); |
2106 |
return !OK; |
2107 |
} |
2108 |
} |
2109 |
|
2110 |
if (!ap_proxy_retry_worker_fn) { |
2111 |
ap_proxy_retry_worker_fn = |
2112 |
APR_RETRIEVE_OPTIONAL_FN(ap_proxy_retry_worker); |
2113 |
if (!ap_proxy_retry_worker_fn) { |
2114 |
ap_log_error(APLOG_MARK, APLOG_EMERG, 0, s, APLOGNO() |
2115 |
"mod_proxy must be loaded for mod_proxy_http"); |
2116 |
return !OK; |
2117 |
} |
2118 |
} |
2119 |
|
2037 |
return OK; |
2120 |
return OK; |
2038 |
} |
2121 |
} |
2039 |
|
2122 |
|