httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ian Holsman <li...@holsman.net>
Subject [patch] FCGI -- pass path-info to FCGI process
Date Thu, 05 Jan 2006 09:24:09 GMT
this allows you to pass a 'path' to the fast cgi process
to use:
ProxyPass  /forum fcgi-tcp://127.0.0.1:8005/foruX

request
/forum/zx will have a path_info of /foruX/zx

posting it as a patch, as the code is a bit fugly.

Index: mod_proxy_fcgi.c
===================================================================
--- mod_proxy_fcgi.c    (revision 366086)
+++ mod_proxy_fcgi.c    (working copy)
@@ -28,6 +28,7 @@
 static int proxy_fcgi_canon(request_rec *r, char *url)
 {
     char *host, sport[7];
+    char *path;
     const char *err;
     const char* scheme;
     apr_port_t port = 8000;
@@ -62,8 +63,13 @@
             host = apr_pstrcat(r->pool, "[", host, "]", NULL);
         }
         
-        r->filename = apr_pstrcat(r->pool, "proxy:", scheme, host, 
sport, "/",
+        path = ap_proxy_canonenc(r->pool, url, strlen(url), enc_path, 
0, r->proxyreq);
+        if (path == NULL)
+            return HTTP_BAD_REQUEST;
+
+        r->filename = apr_pstrcat(r->pool, "proxy:", scheme, host, 
sport, "/", path,
                                   NULL);
+
     }
     else if (strncmp(url, "local://", 8) == 0) {
         url += 6;
@@ -130,6 +136,7 @@
 {
     const apr_array_header_t *envarr;
     const apr_table_entry_t *elts;
+    char *path;
     struct iovec vec[2];
     fcgi_header header;
     apr_size_t bodylen;
@@ -143,6 +150,18 @@
     ap_add_common_vars(r);
     ap_add_cgi_vars(r);
 
+    if (r->path_info) {
+        apr_table_setn(r->subprocess_env, "PATH_INFO", r->path_info);
+    }
+    else {
+        path = ap_strchr_c( r->filename,'/');
+        if (path) {
+            path = ap_strchr_c( path,':');
+        }
+        if (path) {
+            apr_table_setn(r->subprocess_env, "PATH_INFO",  
ap_strchr_c(path, '/'));
+        }
+    }
     /* XXX are there any FastCGI specific env vars we need to send? */
 
     /* XXX What if there is over 64k worth of data in the env? */


Mime
View raw message