mirror of
https://github.com/apache/httpd.git
synced 2025-08-08 15:02:10 +03:00
Add ap_proxy_pre_request API function.
It calls the actual module pre_request hook if present Submitted by: mturk git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@104578 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -249,11 +249,13 @@ struct proxy_balancer {
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/* data structure for set/get module_config */
|
/* per connection data structure for set/get module_config */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char *url; /* rewtitten url */
|
char *url; /* rewtitten url */
|
||||||
struct proxy_balancer *balancer; /* load balancer to use */
|
struct proxy_balancer *balancer; /* load balancer to use */
|
||||||
proxy_worker *worker; /* most suitable worker */
|
proxy_worker *worker; /* most suitable worker */
|
||||||
|
proxy_conn_rec *conn_rec;
|
||||||
|
proxy_conn *conn;
|
||||||
void *opaque; /* module private data */
|
void *opaque; /* module private data */
|
||||||
} proxy_module_conf;
|
} proxy_module_conf;
|
||||||
|
|
||||||
@@ -350,7 +352,7 @@ PROXY_DECLARE(const char *) ap_proxy_add_worker(proxy_worker **worker, apr_pool_
|
|||||||
PROXY_DECLARE(struct proxy_balancer *) ap_proxy_get_balancer(apr_pool_t *p, proxy_server_conf *conf, const char *url);
|
PROXY_DECLARE(struct proxy_balancer *) ap_proxy_get_balancer(apr_pool_t *p, proxy_server_conf *conf, const char *url);
|
||||||
PROXY_DECLARE(const char *) ap_proxy_add_balancer(struct proxy_balancer **balancer, apr_pool_t *p, proxy_server_conf *conf, const char *url);
|
PROXY_DECLARE(const char *) ap_proxy_add_balancer(struct proxy_balancer **balancer, apr_pool_t *p, proxy_server_conf *conf, const char *url);
|
||||||
PROXY_DECLARE(void) ap_proxy_add_worker_to_balancer(struct proxy_balancer *balancer, proxy_worker *worker);
|
PROXY_DECLARE(void) ap_proxy_add_worker_to_balancer(struct proxy_balancer *balancer, proxy_worker *worker);
|
||||||
|
PROXY_DECLARE(int) ap_proxy_pre_request(proxy_worker **worker, struct proxy_balancer **balancer, request_rec *r, proxy_server_conf *conf, char **url);
|
||||||
|
|
||||||
/* For proxy_util */
|
/* For proxy_util */
|
||||||
extern module PROXY_DECLARE_DATA proxy_module;
|
extern module PROXY_DECLARE_DATA proxy_module;
|
||||||
|
@@ -1192,6 +1192,47 @@ ap_proxy_add_worker_to_balancer(struct proxy_balancer *balancer, proxy_worker *w
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PROXY_DECLARE(int) ap_proxy_pre_request(proxy_worker **worker,
|
||||||
|
struct proxy_balancer **balancer,
|
||||||
|
request_rec *r,
|
||||||
|
proxy_server_conf *conf, char **url)
|
||||||
|
{
|
||||||
|
int access_status;
|
||||||
|
|
||||||
|
access_status = proxy_run_pre_request(worker, balancer, r, conf, url);
|
||||||
|
if (access_status == DECLINED && *balancer == NULL) {
|
||||||
|
*worker = ap_proxy_get_worker(r->pool, conf, *url);
|
||||||
|
if (*worker) {
|
||||||
|
*balancer = NULL;
|
||||||
|
access_status = OK;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
access_status = DECLINED;
|
||||||
|
}
|
||||||
|
else if (access_status == DECLINED && balancer != NULL) {
|
||||||
|
/* All the workers are busy */
|
||||||
|
access_status = HTTP_SERVICE_UNAVAILABLE;
|
||||||
|
}
|
||||||
|
return access_status;
|
||||||
|
}
|
||||||
|
|
||||||
|
PROXY_DECLARE(int) ap_proxy_post_request(proxy_worker *worker,
|
||||||
|
struct proxy_balancer *balancer,
|
||||||
|
request_rec *r,
|
||||||
|
proxy_server_conf *conf)
|
||||||
|
{
|
||||||
|
int access_status;
|
||||||
|
if (balancer)
|
||||||
|
access_status = proxy_run_post_request(worker, balancer, r, conf);
|
||||||
|
else {
|
||||||
|
|
||||||
|
|
||||||
|
access_status = OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
return access_status;
|
||||||
|
}
|
||||||
|
|
||||||
PROXY_DECLARE(int) ap_proxy_connect_to_backend(apr_socket_t **newsock,
|
PROXY_DECLARE(int) ap_proxy_connect_to_backend(apr_socket_t **newsock,
|
||||||
const char *proxy_function,
|
const char *proxy_function,
|
||||||
apr_sockaddr_t *backend_addr,
|
apr_sockaddr_t *backend_addr,
|
||||||
|
Reference in New Issue
Block a user