You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by st...@apache.org on 2005/01/07 23:17:50 UTC

svn commit: r124584 - /httpd/httpd/trunk/modules/mappers/mod_rewrite.c /httpd/httpd/trunk/modules/proxy/ajp.h /httpd/httpd/trunk/modules/proxy/ajp_header.c /httpd/httpd/trunk/modules/proxy/proxy_ajp.c

Author: striker
Date: Fri Jan  7 14:17:48 2005
New Revision: 124584

URL: http://svn.apache.org/viewcvs?view=rev&rev=124584
Log:
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.

Modified:
   httpd/httpd/trunk/modules/mappers/mod_rewrite.c
   httpd/httpd/trunk/modules/proxy/ajp.h
   httpd/httpd/trunk/modules/proxy/ajp_header.c
   httpd/httpd/trunk/modules/proxy/proxy_ajp.c

Modified: httpd/httpd/trunk/modules/mappers/mod_rewrite.c
Url: http://svn.apache.org/viewcvs/httpd/httpd/trunk/modules/mappers/mod_rewrite.c?view=diff&rev=124584&p1=httpd/httpd/trunk/modules/mappers/mod_rewrite.c&r1=124583&p2=httpd/httpd/trunk/modules/mappers/mod_rewrite.c&r2=124584
==============================================================================
--- httpd/httpd/trunk/modules/mappers/mod_rewrite.c	(original)
+++ httpd/httpd/trunk/modules/mappers/mod_rewrite.c	Fri Jan  7 14:17:48 2005
@@ -558,6 +558,19 @@
     }
 
     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://    */

Modified: httpd/httpd/trunk/modules/proxy/ajp.h
Url: http://svn.apache.org/viewcvs/httpd/httpd/trunk/modules/proxy/ajp.h?view=diff&rev=124584&p1=httpd/httpd/trunk/modules/proxy/ajp.h&r1=124583&p2=httpd/httpd/trunk/modules/proxy/ajp.h&r2=124584
==============================================================================
--- httpd/httpd/trunk/modules/proxy/ajp.h	(original)
+++ httpd/httpd/trunk/modules/proxy/ajp.h	Fri Jan  7 14:17:48 2005
@@ -384,9 +384,11 @@
  * 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.

Modified: httpd/httpd/trunk/modules/proxy/ajp_header.c
Url: http://svn.apache.org/viewcvs/httpd/httpd/trunk/modules/proxy/ajp_header.c?view=diff&rev=124584&p1=httpd/httpd/trunk/modules/proxy/ajp_header.c&r1=124583&p2=httpd/httpd/trunk/modules/proxy/ajp_header.c&r2=124584
==============================================================================
--- httpd/httpd/trunk/modules/proxy/ajp_header.c	(original)
+++ httpd/httpd/trunk/modules/proxy/ajp_header.c	Fri Jan  7 14:17:48 2005
@@ -203,14 +203,14 @@
 
  */
 
-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 @@
 
     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 @@
         }
     }
     /* 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 @@
  * 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 @@
         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");

Modified: httpd/httpd/trunk/modules/proxy/proxy_ajp.c
Url: http://svn.apache.org/viewcvs/httpd/httpd/trunk/modules/proxy/proxy_ajp.c?view=diff&rev=124584&p1=httpd/httpd/trunk/modules/proxy/proxy_ajp.c&r1=124583&p2=httpd/httpd/trunk/modules/proxy/proxy_ajp.c&r2=124584
==============================================================================
--- httpd/httpd/trunk/modules/proxy/proxy_ajp.c	(original)
+++ httpd/httpd/trunk/modules/proxy/proxy_ajp.c	Fri Jan  7 14:17:48 2005
@@ -116,8 +116,8 @@
     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 @@
      */
 
     /* 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 @@
 }
 
 /*
- * 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,