mirror of
https://github.com/apache/httpd.git
synced 2025-08-08 15:02:10 +03:00
Add canon_handler for load balancer so that we have
query string passed to remote. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@160675 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -24,6 +24,57 @@
|
||||
|
||||
module AP_MODULE_DECLARE_DATA proxy_balancer_module;
|
||||
|
||||
static int proxy_balancer_canon(request_rec *r, char *url)
|
||||
{
|
||||
char *host, *path, *search;
|
||||
const char *err;
|
||||
const char *scheme;
|
||||
apr_port_t port = 0;
|
||||
|
||||
if (strncasecmp(url, "balancer:", 9) == 0) {
|
||||
url += 9;
|
||||
scheme = "balancer";
|
||||
}
|
||||
else {
|
||||
return DECLINED;
|
||||
}
|
||||
|
||||
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
|
||||
"proxy: BALANCER: canonicalising URL %s", url);
|
||||
|
||||
/* do syntatic check.
|
||||
* We break the URL into host, port, path, search
|
||||
*/
|
||||
err = ap_proxy_canon_netloc(r->pool, &url, NULL, NULL, &host, &port);
|
||||
if (err) {
|
||||
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
|
||||
"error parsing URL %s: %s",
|
||||
url, err);
|
||||
return HTTP_BAD_REQUEST;
|
||||
}
|
||||
/* now parse path/search args, according to rfc1738 */
|
||||
/* N.B. if this isn't a true proxy request, then the URL _path_
|
||||
* has already been decoded. True proxy requests have r->uri
|
||||
* == r->unparsed_uri, and no others have that property.
|
||||
*/
|
||||
if (r->uri == r->unparsed_uri) {
|
||||
search = strchr(url, '?');
|
||||
if (search != NULL)
|
||||
*(search++) = '\0';
|
||||
}
|
||||
else
|
||||
search = r->args;
|
||||
|
||||
/* process path */
|
||||
path = ap_proxy_canonenc(r->pool, url, strlen(url), enc_path, 0, r->proxyreq);
|
||||
if (path == NULL)
|
||||
return HTTP_BAD_REQUEST;
|
||||
|
||||
r->filename = apr_pstrcat(r->pool, "proxy:", scheme, "://", host,
|
||||
"/", path, (search) ? "?" : "", (search) ? search : "", NULL);
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int init_balancer_members(proxy_server_conf *conf, server_rec *s,
|
||||
proxy_balancer *balancer)
|
||||
{
|
||||
@@ -824,6 +875,7 @@ static void ap_proxy_balancer_register_hook(apr_pool_t *p)
|
||||
ap_hook_child_init(child_init, aszPred, NULL, APR_HOOK_MIDDLE);
|
||||
proxy_hook_pre_request(proxy_balancer_pre_request, NULL, NULL, APR_HOOK_FIRST);
|
||||
proxy_hook_post_request(proxy_balancer_post_request, NULL, NULL, APR_HOOK_FIRST);
|
||||
proxy_hook_canon_handler(proxy_balancer_canon, NULL, NULL, APR_HOOK_FIRST);
|
||||
}
|
||||
|
||||
module AP_MODULE_DECLARE_DATA proxy_balancer_module = {
|
||||
|
Reference in New Issue
Block a user