You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by pq...@apache.org on 2005/12/23 04:16:15 UTC

svn commit: r358690 - /httpd/httpd/branches/fcgi-proxy-dev/modules/proxy/mod_proxy_fcgi.c

Author: pquerna
Date: Thu Dec 22 19:16:07 2005
New Revision: 358690

URL: http://svn.apache.org/viewcvs?rev=358690&view=rev
Log:
Fix the parsing of the protocol in ProxyPass, so now you can do:
  ProxyPass / fcgi-tcp://localhost:9000/, and we will try to connect with TCP.

I still need to write supporting code to send/recv the FastCGI protocol packets.

Modified:
    httpd/httpd/branches/fcgi-proxy-dev/modules/proxy/mod_proxy_fcgi.c

Modified: httpd/httpd/branches/fcgi-proxy-dev/modules/proxy/mod_proxy_fcgi.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/branches/fcgi-proxy-dev/modules/proxy/mod_proxy_fcgi.c?rev=358690&r1=358689&r2=358690&view=diff
==============================================================================
--- httpd/httpd/branches/fcgi-proxy-dev/modules/proxy/mod_proxy_fcgi.c (original)
+++ httpd/httpd/branches/fcgi-proxy-dev/modules/proxy/mod_proxy_fcgi.c Thu Dec 22 19:16:07 2005
@@ -28,20 +28,47 @@
 {
     char *host, *path, *search, sport[7];
     const char *err;
+    const char* scheme;
     apr_port_t port = 8000;
 
-    if (strncasecmp(url, "fcgi:", 5) == 0) {
+    if (strncasecmp(url, "fcgi-", 5) == 0) {
         url += 5;
     }
     else {
         return DECLINED;
     }
     
+    ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+                 "proxy: FCGI: canonicalising URL %s", url);
+
     if (strncmp(url, "tcp://", 6) == 0) {
-        url += 6;
+        url += 4;
+        
+        scheme = "fcgi-tcp://";
+
+        err = ap_proxy_canon_netloc(r->pool, &url, NULL, NULL, &host, &port);
+        if (err) {
+            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+                          "error parsing URL %s: %s",
+                          url, err);
+            return HTTP_BAD_REQUEST;
+        }
+        
+        apr_snprintf(sport, sizeof(sport), ":%d", port);
+        
+        if (ap_strchr_c(host, ':')) {
+            /* if literal IPv6 address */
+            host = apr_pstrcat(r->pool, "[", host, "]", NULL);
+        }
+        
+        r->filename = apr_pstrcat(r->pool, "proxy:", scheme, host, sport, "/", NULL);
     }
-    else if (strncmp(url, "local:", 6) == 0) {
+    else if (strncmp(url, "local://", 8) == 0) {
         url += 6;
+        scheme = "fcgi-local:";
+        ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
+                     "proxy: FCGI: Local FastCGI not supported.");
+        return HTTP_INTERNAL_SERVER_ERROR;
     }
     else {
         ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
@@ -49,51 +76,6 @@
         return HTTP_INTERNAL_SERVER_ERROR;
     }
 
-
-    /*
-     * do syntactic check.
-     * We break the URL into host, port, path, search
-     */
-    err = ap_proxy_canon_netloc(r->pool, &url, NULL, NULL, &host, &port);
-    if (err) {
-        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
-                      "error parsing URL %s: %s",
-                      url, err);
-        return HTTP_BAD_REQUEST;
-    }
-
-    /*
-     * now parse path/search args, according to rfc1738
-     *
-     * N.B. if this isn't a true proxy request, then the URL _path_
-     * has already been decoded.  True proxy requests have
-     * r->uri == r->unparsed_uri, and no others have that property.
-     */
-    if (r->uri == r->unparsed_uri) {
-        search = strchr(url, '?');
-        if (search != NULL)
-            *(search++) = '\0';
-    }
-    else {
-        search = r->args;
-    }
-
-    /* process path */
-    path = ap_proxy_canonenc(r->pool, url, strlen(url), enc_path, 0,
-                             r->proxyreq);
-    if (path == NULL) {
-        return HTTP_BAD_REQUEST;
-    }
-
-    apr_snprintf(sport, sizeof(sport), ":%d", port);
-
-    if (ap_strchr_c(host, ':')) {
-        /* if literal IPv6 address */
-        host = apr_pstrcat(r->pool, "[", host, "]", NULL);
-    }
-    r->filename = apr_pstrcat(r->pool, "proxy:ajp://", host, sport,
-                              "/", path, (search) ? "?" : "",
-                              (search) ? search : "", NULL);
     return OK;
 }
 
@@ -132,7 +114,10 @@
     apr_uri_t *uri = apr_palloc(r->pool, sizeof(*uri));
 
 
-    if (strncasecmp(url, "fcgi:", 5) == 0) {
+    ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
+                 "proxy: FCGI: url: %s proxyname: %s proxyport: %d", url, proxyname, proxyport);
+
+    if (strncasecmp(url, "fcgi-", 5) == 0) {
         url += 5;
     }
     else {
@@ -144,8 +129,11 @@
     if (strncmp(url, "tcp://", 6) == 0) {
         scheme = "FCGI_TCP";
     }
-    else if (strncmpp(url, "local:", 6) == 0) {
+    else if (strncmp(url, "local://", 8) == 0) {
         scheme = "FCGI_LOCAL";
+        ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
+                     "proxy: FCGI: local FastCGI not supported.");
+        return HTTP_INTERNAL_SERVER_ERROR;
     }
     else {
         ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,