mirror of
https://github.com/apache/httpd.git
synced 2025-08-08 15:02:10 +03:00
mod_proxy: follow up to r1918626: Simplify ap_proxy_fixup_uds_filename() and callers.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1918647 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -1328,8 +1328,7 @@ static int proxy_handler(request_rec *r)
|
|||||||
r->filename = apr_pstrcat(r->pool, r->handler, r->filename, NULL);
|
r->filename = apr_pstrcat(r->pool, r->handler, r->filename, NULL);
|
||||||
|
|
||||||
/* Still need to fixup/canonicalize r->filename */
|
/* Still need to fixup/canonicalize r->filename */
|
||||||
uri = r->filename + 6;
|
rc = ap_proxy_fixup_uds_filename(r);
|
||||||
rc = ap_proxy_fixup_uds_filename(r, &uri);
|
|
||||||
if (rc <= OK) {
|
if (rc <= OK) {
|
||||||
rc = proxy_fixup(r);
|
rc = proxy_fixup(r);
|
||||||
}
|
}
|
||||||
|
@@ -1030,14 +1030,12 @@ PROXY_DECLARE(proxy_balancer_shared *) ap_proxy_find_balancershm(ap_slotmem_prov
|
|||||||
unsigned int *index);
|
unsigned int *index);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* In the case of the reverse proxy, we need to see if we
|
* Strip the UDS part of r->filename if any, and put the UDS path in
|
||||||
* were passed a UDS url (eg: from mod_proxy) and adjust uds_path
|
* r->notes ("uds_path")
|
||||||
* as required.
|
|
||||||
* @param r current request
|
* @param r current request
|
||||||
* @param url request url to be fixed
|
|
||||||
* @return OK if fixed up, DECLINED if not UDS, or an HTTP_XXX error
|
* @return OK if fixed up, DECLINED if not UDS, or an HTTP_XXX error
|
||||||
*/
|
*/
|
||||||
PROXY_DECLARE(int) ap_proxy_fixup_uds_filename(request_rec *r, char **url);
|
PROXY_DECLARE(int) ap_proxy_fixup_uds_filename(request_rec *r);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the most suitable worker and/or balancer for the request
|
* Get the most suitable worker and/or balancer for the request
|
||||||
|
@@ -2425,7 +2425,7 @@ static int ap_proxy_retry_worker(const char *proxy_function, proxy_worker *worke
|
|||||||
* were passed a UDS url (eg: from mod_proxy) and adjust uds_path
|
* were passed a UDS url (eg: from mod_proxy) and adjust uds_path
|
||||||
* as required.
|
* as required.
|
||||||
*/
|
*/
|
||||||
PROXY_DECLARE(int) ap_proxy_fixup_uds_filename(request_rec *r, char **url)
|
PROXY_DECLARE(int) ap_proxy_fixup_uds_filename(request_rec *r)
|
||||||
{
|
{
|
||||||
char *uds_url = r->filename + 6, *origin_url;
|
char *uds_url = r->filename + 6, *origin_url;
|
||||||
|
|
||||||
@@ -2433,7 +2433,6 @@ PROXY_DECLARE(int) ap_proxy_fixup_uds_filename(request_rec *r, char **url)
|
|||||||
!ap_cstr_casecmpn(uds_url, "unix:", 5) &&
|
!ap_cstr_casecmpn(uds_url, "unix:", 5) &&
|
||||||
(origin_url = ap_strchr(uds_url + 5, '|'))) {
|
(origin_url = ap_strchr(uds_url + 5, '|'))) {
|
||||||
char *uds_path = NULL;
|
char *uds_path = NULL;
|
||||||
apr_size_t url_len;
|
|
||||||
apr_uri_t urisock;
|
apr_uri_t urisock;
|
||||||
apr_status_t rv;
|
apr_status_t rv;
|
||||||
|
|
||||||
@@ -2452,14 +2451,12 @@ PROXY_DECLARE(int) ap_proxy_fixup_uds_filename(request_rec *r, char **url)
|
|||||||
}
|
}
|
||||||
apr_table_setn(r->notes, "uds_path", uds_path);
|
apr_table_setn(r->notes, "uds_path", uds_path);
|
||||||
|
|
||||||
/* Remove the UDS path from *url and r->filename */
|
|
||||||
url_len = strlen(origin_url);
|
|
||||||
*url = apr_pstrmemdup(r->pool, origin_url, url_len);
|
|
||||||
memcpy(uds_url, *url, url_len + 1);
|
|
||||||
|
|
||||||
ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, r,
|
ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, r,
|
||||||
"*: rewrite of url due to UDS(%s): %s (%s)",
|
"*: fixup UDS from %s: %s (%s)",
|
||||||
uds_path, *url, r->filename);
|
r->filename, origin_url, uds_path);
|
||||||
|
|
||||||
|
/* Overwrite the UDS part in place */
|
||||||
|
memmove(uds_url, origin_url, strlen(origin_url) + 1);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2521,10 +2518,17 @@ PROXY_DECLARE(int) ap_proxy_pre_request(proxy_worker **worker,
|
|||||||
access_status = HTTP_SERVICE_UNAVAILABLE;
|
access_status = HTTP_SERVICE_UNAVAILABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (access_status == OK
|
if (access_status == OK && r->proxyreq == PROXYREQ_REVERSE) {
|
||||||
&& r->proxyreq == PROXYREQ_REVERSE
|
int rc = ap_proxy_fixup_uds_filename(r);
|
||||||
&& ap_proxy_fixup_uds_filename(r, url) > OK) {
|
if (ap_is_HTTP_ERROR(rc)) {
|
||||||
return HTTP_INTERNAL_SERVER_ERROR;
|
return rc;
|
||||||
|
}
|
||||||
|
/* If the URL has changed in r->filename, take everything after
|
||||||
|
* the "proxy:" prefix.
|
||||||
|
*/
|
||||||
|
if (rc == OK) {
|
||||||
|
*url = apr_pstrdup(r->pool, r->filename + 6);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return access_status;
|
return access_status;
|
||||||
|
Reference in New Issue
Block a user