]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Make the combination of mod_proxy_ajp and mod_rewrite work correctly.
authorSander Striker <striker@apache.org>
Fri, 7 Jan 2005 22:17:48 +0000 (22:17 +0000)
committerSander Striker <striker@apache.org>
Fri, 7 Jan 2005 22:17:48 +0000 (22:17 +0000)
* 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

modules/mappers/mod_rewrite.c
modules/proxy/ajp.h
modules/proxy/ajp_header.c
modules/proxy/proxy_ajp.c

index 7e30d9fe9b1a87888d1f5a011130e416a3d03746..0195b1fff6ebbbcafda43b8f71c0c14cf75f1a4e 100644 (file)
@@ -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://    */
index 674a49b6e0d277f2b62226d3cddeb6ab6dd76cf2..c7978b8bb13b920bb63b438654e69522b27787df 100644 (file)
@@ -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.
index c383f959dd79a31b323d8e1f61333bbf8c18497c..30110e523f7d17313bb12a3a00d4b926c6bb6ad6 100644 (file)
@@ -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");
index f2760631e929a3ef537fd23aeaa540e7293c2857..03903edaf36c55d2f0ac6ceb3828c06ef442dba6 100644 (file)
@@ -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,