httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@engelschall.com (Ralf S. Engelschall)
Subject [PATCH] Unbundle mod_proxy and mod_mime (take 2)
Date Fri, 13 Mar 1998 09:27:20 GMT

Unbundle mod_proxy and mod_mime (take 2)
----------------------------------------

The following patch successfully unbundles the proxy module and the mime
module. This is especially essential to be able to compile these two modules
as shared objects. Because in the past you have to compile mod_mime statically
because of this cross-module function call. On the other hand compiling in
mod_proxy implied compiling in of mod_mime. This especially was ugly for the
situation where Apache was used as a Reverse Proxy, because there you only
need mod_proxy (and only for HTTP) and mod_rewrite.  But you were forced to
compile mod_mime into the binary, too.  This restriction is now obsolete, too.
(Because mime_find_ct() was only needed for FTP which is not needed in a
reverse proxy ;_)

The problem here was this: The cross-module function call was introduced in
the past because of too much optimization in the request processing in the
Apache kernel. This way the proxy module has to do the stuff again manually
which is now avoided by making sure we only optimize the processing for
situations where it is safe to optimize.

                                       Ralf S. Engelschall
                                       rse@engelschall.com
                                       www.engelschall.com

Index: CHANGES
===================================================================
RCS file: /e/apache/REPOS/apache-1.3/src/CHANGES,v
retrieving revision 1.703
diff -u -r1.703 CHANGES
--- CHANGES	1998/03/13 07:49:19	1.703
+++ CHANGES	1998/03/13 09:24:07
@@ -1,5 +1,16 @@
 Changes with Apache 1.3b6
 
+  *) Making the hard-coded cross-module function call mime_find_ct() (from
+     mod_proxy to mod_mime) obsolete by making sure the API hook for MIME type
+     checking is really called even for proxy requests except for URLs with
+     HTTP schemes (because there we can optimize by not running the type
+     checking hooks due to the fact that the proxy gets the MIME Content-type
+     from the remote host later). This change cleans up mod_mime by removing
+     the ugly export kludge, makes the one-liner file mod_mime.h obsolete, and
+     especially unbundles mod_proxy and mod_mime. This way they both now can
+     be compiled as shared objects and are no longer tied together. 
+     [Ralf S.  Engelschall]
+
   *) Performance improvements to invoke_handler().
      [Dmitry Khrustalev <dima@bog.msu.su>]
 
Index: main/http_request.c
===================================================================
RCS file: /e/apache/REPOS/apache-1.3/src/main/http_request.c,v
retrieving revision 1.111
diff -u -r1.111 http_request.c
--- http_request.c	1998/03/06 09:37:06	1.111
+++ http_request.c	1998/03/13 09:19:20
@@ -1127,11 +1127,14 @@
         break;
     }
 
-    if (!r->proxyreq)
-      if ((access_status = find_types(r)) != 0) {
-          decl_die(access_status, "find types", r);
-          return;
-      }
+    if (! (r->proxyreq 
+	   && r->parsed_uri.scheme != NULL
+	   && strcmp(r->parsed_uri.scheme, "http") == 0) ) {
+	if ((access_status = find_types(r)) != 0) {
+	    decl_die(access_status, "find types", r);
+	    return;
+	}
+    }
 
     if ((access_status = run_fixups(r)) != 0) {
         die(access_status, r);
Index: modules/proxy/proxy_ftp.c
===================================================================
RCS file: /e/apache/REPOS/apache-1.3/src/modules/proxy/proxy_ftp.c,v
retrieving revision 1.49
diff -u -r1.49 proxy_ftp.c
--- proxy_ftp.c	1998/02/22 21:35:31	1.49
+++ proxy_ftp.c	1998/03/13 09:09:36
@@ -55,7 +55,6 @@
 
 #include "mod_proxy.h"
 #include "http_main.h"
-#include "../standard/mod_mime.h"
 
 DEF_Explain
 
@@ -929,7 +928,6 @@
     if (parms[0] == 'd')
 	proxy_add_header(resp_hdrs, "Content-Type", "text/html", HDR_REP);
     else {
-	mime_find_ct(r);
 	if (r->content_type != NULL) {
 	    proxy_add_header(resp_hdrs, "Content-Type", r->content_type,
 			     HDR_REP);
Index: modules/standard/mod_mime.c
===================================================================
RCS file: /e/apache/REPOS/apache-1.3/src/modules/standard/mod_mime.c,v
retrieving revision 1.34
diff -u -r1.34 mod_mime.c
--- mod_mime.c	1998/03/12 13:37:51	1.34
+++ mod_mime.c	1998/03/13 09:19:51
@@ -237,7 +237,6 @@
     cfg_closefile(f);
 }
 
-/* note that the proxy module uses this via mime_find_ct */
 static int find_ct(request_rec *r)
 {
     const char *fn = strrchr(r->filename, '/');
@@ -323,11 +322,6 @@
         return DECLINED;
 
     return OK;
-}
-
-API_EXPORT(int) mime_find_ct(request_rec *r)
-{
-    return find_ct(r);
 }
 
 module MODULE_VAR_EXPORT mime_module =
Index: modules/standard/mod_mime.h
===================================================================
RCS file: /e/apache/REPOS/apache-1.3/src/modules/standard/mod_mime.h,v
retrieving revision 1.1
diff -u -r1.1 mod_mime.h
--- mod_mime.h	1997/07/19 20:16:15	1.1
+++ mod_mime.h	1998/03/12 14:35:19
@@ -1 +0,0 @@
-API_EXPORT(int) mime_find_ct(request_rec *r);

Mime
View raw message