unsigned int *index);
/*
- * In the case of the reverse proxy, we need to see if we
- * were passed a UDS url (eg: from mod_proxy) and adjust uds_path
- * as required.
+ * Strip the UDS part of r->filename if any, and put the UDS path in
+ * r->notes ("uds_path")
* @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
*/
-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
* were passed a UDS url (eg: from mod_proxy) and adjust uds_path
* 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;
!ap_cstr_casecmpn(uds_url, "unix:", 5) &&
(origin_url = ap_strchr(uds_url + 5, '|'))) {
char *uds_path = NULL;
- apr_size_t url_len;
apr_uri_t urisock;
apr_status_t rv;
}
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,
- "*: rewrite of url due to UDS(%s): %s (%s)",
- uds_path, *url, r->filename);
+ "*: fixup UDS from %s: %s (%s)",
+ r->filename, origin_url, uds_path);
+
+ /* Overwrite the UDS part in place */
+ memmove(uds_url, origin_url, strlen(origin_url) + 1);
return OK;
}
access_status = HTTP_SERVICE_UNAVAILABLE;
}
- if (access_status == OK
- && r->proxyreq == PROXYREQ_REVERSE
- && ap_proxy_fixup_uds_filename(r, url) > OK) {
- return HTTP_INTERNAL_SERVER_ERROR;
+ if (access_status == OK && r->proxyreq == PROXYREQ_REVERSE) {
+ int rc = ap_proxy_fixup_uds_filename(r);
+ if (ap_is_HTTP_ERROR(rc)) {
+ 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;