From: Sander Striker Date: Fri, 7 Jan 2005 22:17:48 +0000 (+0000) Subject: Make the combination of mod_proxy_ajp and mod_rewrite work correctly. X-Git-Tag: 2.1.3~168 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=47c6e884b2614c7c3e812f82441a6d9cb909d320;p=thirdparty%2Fapache%2Fhttpd.git Make the combination of mod_proxy_ajp and mod_rewrite work correctly. * modules/proxy/proxy_ajp.c (ap_proxy_ajp_request): Update call to ajp_send_header(). * modules/proxy/ajp.h (ajp_send_header): Add a uri parameter. * modules/proxy/ajp_header.c (ajp_marshal_into_msgb): Add a uri parameter and use the passed in uri instead of r->uri. (ajp_send_header): Add a uri parameter. Update call to ajp_marshal_into_msgb(). * modules/mappers/mod_rewrite.c (is_absolute_uri): Add handling of 'ajp' and 'balancer' schemes. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@124584 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/mappers/mod_rewrite.c b/modules/mappers/mod_rewrite.c index 7e30d9fe9b1..0195b1fff6e 100644 --- a/modules/mappers/mod_rewrite.c +++ b/modules/mappers/mod_rewrite.c @@ -558,6 +558,19 @@ static unsigned is_absolute_uri(char *uri) } switch (*uri++) { + case 'a': + case 'A': + if (!strncasecmp(uri, "jp://", 5)) { /* ajp:// */ + return 6; + } + + case 'b': + case 'B': + if (!strncasecmp(uri, "alancer://", 10)) { /* balancer:// */ + return 11; + } + break; + case 'f': case 'F': if (!strncasecmp(uri, "tp://", 5)) { /* ftp:// */ diff --git a/modules/proxy/ajp.h b/modules/proxy/ajp.h index 674a49b6e0d..c7978b8bb13 100644 --- a/modules/proxy/ajp.h +++ b/modules/proxy/ajp.h @@ -384,9 +384,11 @@ apr_status_t ajp_ilink_receive(apr_socket_t *sock, ajp_msg_t *msg); * Build the ajp header message and send it * @param sock backend socket * @param r current request + * @uri uri requested uri * @return APR_SUCCESS or error */ -apr_status_t ajp_send_header(apr_socket_t *sock, request_rec *r); +apr_status_t ajp_send_header(apr_socket_t *sock, request_rec *r, + apr_uri_t *uri); /** * Read the ajp message and return the type of the message. diff --git a/modules/proxy/ajp_header.c b/modules/proxy/ajp_header.c index c383f959dd7..30110e523f7 100644 --- a/modules/proxy/ajp_header.c +++ b/modules/proxy/ajp_header.c @@ -203,14 +203,14 @@ AJPV13_REQUEST/AJPV14_REQUEST= */ -static apr_status_t ajp_marshal_into_msgb(ajp_msg_t *msg, - request_rec *r) +static apr_status_t ajp_marshal_into_msgb(ajp_msg_t *msg, + request_rec *r, + apr_uri_t *uri) { int method; apr_uint32_t i, num_headers = 0; apr_byte_t is_ssl; char *remote_host; - char *uri; const char *session_route, *envvar; const apr_array_header_t *arr = apr_table_elts(r->subprocess_env); const apr_table_entry_t *elts = (const apr_table_entry_t *)arr->elts; @@ -235,21 +235,12 @@ static apr_status_t ajp_marshal_into_msgb(ajp_msg_t *msg, remote_host = (char *)ap_get_remote_host(r->connection, r->per_dir_config, REMOTE_HOST, NULL); - uri = apr_pstrdup(r->pool, r->uri); - if (uri != NULL) { - char *query_str = strchr(uri, '?'); - if (query_str != NULL) { - *query_str = 0; - } - } - - ajp_msg_reset(msg); if (ajp_msg_append_uint8(msg, CMD_AJP13_FORWARD_REQUEST) || ajp_msg_append_uint8(msg, method) || ajp_msg_append_string(msg, r->protocol) || - ajp_msg_append_string(msg, uri) || + ajp_msg_append_string(msg, uri->path) || ajp_msg_append_string(msg, r->connection->remote_ip) || ajp_msg_append_string(msg, remote_host) || ajp_msg_append_string(msg, ap_get_server_name(r)) || @@ -327,9 +318,9 @@ static apr_status_t ajp_marshal_into_msgb(ajp_msg_t *msg, } } /* XXXX ebcdic (args converted?) */ - if (r->args) { + if (uri->query) { if (ajp_msg_append_uint8(msg, SC_A_QUERY_STRING) || - ajp_msg_append_string(msg, r->args)) { + ajp_msg_append_string(msg, uri->query)) { ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server, "Error ajp_marshal_into_msgb - " "Error appending the query string"); @@ -563,7 +554,8 @@ static apr_status_t ajp_unmarshal_response(ajp_msg_t *msg, * Build the ajp header message and send it */ apr_status_t ajp_send_header(apr_socket_t *sock, - request_rec *r) + request_rec *r, + apr_uri_t *uri) { ajp_msg_t *msg; apr_status_t rc; @@ -575,7 +567,7 @@ apr_status_t ajp_send_header(apr_socket_t *sock, return rc; } - rc = ajp_marshal_into_msgb(msg, r); + rc = ajp_marshal_into_msgb(msg, r, uri); if (rc != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server, "ajp_send_header: ajp_marshal_into_msgb failed"); diff --git a/modules/proxy/proxy_ajp.c b/modules/proxy/proxy_ajp.c index f2760631e92..03903edaf36 100644 --- a/modules/proxy/proxy_ajp.c +++ b/modules/proxy/proxy_ajp.c @@ -116,8 +116,8 @@ static int ap_proxy_ajp_request(apr_pool_t *p, request_rec *r, char *buff; apr_uint16_t size; const char *tenc; - int havebody=1; - int isok=1; + int havebody = 1; + int isok = 1; apr_off_t bb_len; /* @@ -125,7 +125,7 @@ static int ap_proxy_ajp_request(apr_pool_t *p, request_rec *r, */ /* send request headers */ - status = ajp_send_header(conn->sock, r); + status = ajp_send_header(conn->sock, r, uri); if (status != APR_SUCCESS) { conn->close++; ap_log_error(APLOG_MARK, APLOG_ERR, status, r->server, @@ -341,7 +341,7 @@ static int ap_proxy_ajp_request(apr_pool_t *p, request_rec *r, } /* - * This handles http:// URLs, and other URLs using a remote proxy over http + * This handles ajp:// URLs, and other URLs using a remote proxy over http * If proxyhost is NULL, then contact the server directly, otherwise * go via the proxy. * Note that if a proxy is used, then URLs other than http: can be accessed,