www-apache-bugdb mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anthony Howe <ach...@snert.com>
Subject Re: mod_userdir/6828: mod_userdir should check for location URIs
Date Tue, 14 Nov 2000 14:21:15 GMT
Here is a proposed patch for mod_userdir.c

An example of this patch in operation can be found here:

        http://www.snert.com:8888/~chrisma/server-info

While the above is not of great interest, the following is now possible:

        http://www.snert.com:8888/~chrisma/throttle-me
        http://www.snert.com:8888/throttle-me

I can now specify a <Location /throttle-me> that invokes the throttle-me 
handler in mod_throttle/3.0 and get different results depending whether
a ~user is specified or not.

----

*** mod_userdir.c.orig	Sat Nov 11 15:37:01 2000
--- mod_userdir.c	Sat Nov 11 15:44:35 2000
***************
*** 92,97 ****
--- 92,98 ----
  
  #include "httpd.h"
  #include "http_config.h"
+ #include "http_request.h"
  
  module userdir_module;
  
***************
*** 308,313 ****
--- 309,315 ----
  #endif                          /* WIN32 & NetWare */
          }
  
+ #ifdef ORIGINAL
          /*
           * Now see if it exists, or we're at the last entry. If we are
at the
           * last entry, then use the filename generated (if there is
one)
***************
*** 323,328 ****
--- 325,373 ----
  		r->finfo = statbuf;
              return OK;
          }
+ 
+ #else
+ 	/* Background: The built-up "filename" will either be null or
+ 	 * contain the document root of the user, "w", derived from one
+ 	 * or more patterns pointed to by "userdirs". The remainder of
+ 	 * the URI is pointed to by "dname", which may be an empty string.
+ 	 *
+ 	 * Check if the user's document root exists or if we are on the
+ 	 * last entry for the list of patterns, in which case we use the
+ 	 * last generated filename in case some handler might handle it,
+ 	 * such as cgi-script.
+ 	 */
+ 	if (filename != (char *) 0) {
+ 		if (*userdirs == '\0') {
+ 			request_rec *sub;
+ 
+ 	        	r->filename = ap_pstrcat(r->pool, filename, dname, NULL);
+ 
+ 			/* Check if the remainder of the URI refers to some
+ 			 * special location or handler and set it as the
+ 			 * default.
+ 			 */
+ 			sub = ap_sub_req_lookup_uri(dname, r);
+ 			if (ap_is_HTTP_SUCCESS(sub->status))
+ 				r->handler = ap_pstrdup(r->pool, sub->handler);
+ 			ap_destroy_sub_req(sub);
+ 
+ 			return OK;
+ 		} else if (stat(filename, &statbuf) == 0) {
+ 	        	r->filename = ap_pstrcat(r->pool, filename, dname, NULL);
+ 
+ 			/* When the URI is just "/~user", then we can save
+ 			 * an additional stat() by saving the information as
+ 			 * part of this request.
+ 			 */
+ 			if (*dname == '\0')
+ 				r->finfo = statbuf;
+ 
+ 			return OK;
+ 		}
+ 	}
+ #endif
+ 
      }
  
      return DECLINED;

-- 
Anthony C Howe          1489 Ch. des Collines, 06110 Le Cannet, France
+33 (0)6 1189 7378 (p)  +33 (0)4 9346 8901 (f)            ICQ# 7116561
mailto:achowe@snert.com                          http://www.snert.com/

Mime
View raw message