You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Ben Laurie <be...@gonzo.ben.algroup.co.uk> on 1997/01/03 17:03:29 UTC

Header Parse API

Here's the patch to add an extra API for header parsing. As you can see, its
pretty simple. I've only added it to the main request processor, and not to the
subrequest processors, on the grounds that the headers from the client only
happen in the main request. There is room for debate here, though.

I've tested it lightly, and BrowserMatch still works, so I guess its mostly OK.
I'd like to commit it so people can test it easily - if its OK then I'll do the
changes for mod_auth to make it user BrowserMatch instead. I will undertake to
remove the changes if, in the end, the mod is not approved.

Cheers,

Ben.

Index: http_config.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_config.c,v
retrieving revision 1.39
diff -c -r1.39 http_config.c
*** http_config.c	1997/01/01 18:10:16	1.39
--- http_config.c	1997/01/03 17:03:08
***************
*** 292,297 ****
--- 292,301 ----
     return run_method (r, XtOffsetOf (module, logger), 1);
  }
  
+ int header_parse (request_rec *r) {
+     return run_method (r, XtOffsetOf (module, header_parser), 1);
+ }
+ 
  /* Auth stuff --- anything that defines one of these will presumably
   * want to define something for the other.  Note that check_auth is
   * separate from check_access to make catching some config errors easier.
Index: http_config.h
===================================================================
RCS file: /export/home/cvs/apache/src/http_config.h,v
retrieving revision 1.26
diff -c -r1.26 http_config.h
*** http_config.h	1997/01/01 18:10:17	1.26
--- http_config.h	1997/01/03 17:03:14
***************
*** 216,221 ****
--- 216,222 ----
      int (*type_checker)(request_rec *);
      int (*fixer_upper)(request_rec *);
      int (*logger)(request_rec *);
+     int (*header_parser)(request_rec *);
  } module;
  
  /* Initializer for the first few module slots, which are only
***************
*** 225,231 ****
   * handle it back-compatibly, or at least signal an error).
   */
  
! #define MODULE_MAGIC_NUMBER 19961211
  #define STANDARD_MODULE_STUFF MODULE_MAGIC_NUMBER, -1, __FILE__, NULL
  
  /* Generic accessors for other modules to get at their own module-specific
--- 226,232 ----
   * handle it back-compatibly, or at least signal an error).
   */
  
! #define MODULE_MAGIC_NUMBER 19970103
  #define STANDARD_MODULE_STUFF MODULE_MAGIC_NUMBER, -1, __FILE__, NULL
  
  /* Generic accessors for other modules to get at their own module-specific
***************
*** 291,295 ****
--- 292,297 ----
  int run_fixups (request_rec *);	/* poke around for other metainfo, etc.... */
  int invoke_handler (request_rec *);     
  int log_transaction (request_rec *r);
+ int header_parse (request_rec *);
  
  #endif
Index: http_request.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_request.c,v
retrieving revision 1.34
diff -c -r1.34 http_request.c
*** http_request.c	1997/01/01 18:10:22	1.34
--- http_request.c	1997/01/03 17:03:23
***************
*** 867,872 ****
--- 867,877 ----
          die (access_status, r);
  	return;
      }	
+ 
+     if ((access_status = header_parse (r))) {
+         die (access_status, r);
+ 	return;
+     }
      
      switch (satisfies(r)) {
      case SATISFY_ALL:
Index: mod_browser.c
===================================================================
RCS file: /export/home/cvs/apache/src/mod_browser.c,v
retrieving revision 1.6
diff -c -r1.6 mod_browser.c
*** mod_browser.c	1997/01/01 18:10:29	1.6
--- mod_browser.c	1997/01/03 17:03:24
***************
*** 138,144 ****
  { NULL },
  };
  
! int fixup_browser_module(request_rec *r)
  {
      server_rec *s = r->server;
      browser_server_config_rec *sconf = get_module_config (s->module_config,
--- 138,144 ----
  { NULL },
  };
  
! int parse_headers_browser_module(request_rec *r)
  {
      server_rec *s = r->server;
      browser_server_config_rec *sconf = get_module_config (s->module_config,
***************
*** 182,187 ****
     NULL,			/* check auth */
     NULL,			/* check access */
     NULL,			/* type_checker */
!    fixup_browser_module,	/* fixups */
     NULL,			/* logger */
  };
--- 182,188 ----
     NULL,			/* check auth */
     NULL,			/* check access */
     NULL,			/* type_checker */
!    NULL,			/* fixups */
     NULL,			/* logger */
+    parse_headers_browser_module,/* header parser */
  };

-- 
Ben Laurie                Phone: +44 (181) 994 6435  Email: ben@algroup.co.uk
Freelance Consultant and  Fax:   +44 (181) 994 6472
Technical Director        URL: http://www.algroup.co.uk/Apache-SSL
A.L. Digital Ltd,         Apache Group member (http://www.apache.org)
London, England.          Apache-SSL author

Re: Header Parse API

Posted by Alexei Kosut <ak...@nueva.pvt.k12.ca.us>.
On Fri, 3 Jan 1997, Ben Laurie wrote:

> Here's the patch to add an extra API for header parsing. As you can see, its
> pretty simple. I've only added it to the main request processor, and not to the
> subrequest processors, on the grounds that the headers from the client only
> happen in the main request. There is room for debate here, though.
> 
> I've tested it lightly, and BrowserMatch still works, so I guess its mostly OK.
> I'd like to commit it so people can test it easily - if its OK then I'll do the
> changes for mod_auth to make it user BrowserMatch instead. I will undertake to
> remove the changes if, in the end, the mod is not approved.

What I'm wondering is how adding the extra slot to the end of the
module structure is going to affect existing modules, which won't have
the extra NULL. Will this compile and run on all compilers? Glancing
at K&R, it would seem to indicate this is legal, but it doesn't give
me the happiest of feelings.

Whatever you do, be sure and bump up the MODULE_MAGIC_NUMBER.

-- 
________________________________________________________________________
Alexei Kosut <ak...@nueva.pvt.k12.ca.us>      The Apache HTTP Server
URL: http://www.nueva.pvt.k12.ca.us/~akosut/   http://www.apache.org/




Re: Header Parse API

Posted by Di...@jrc.it.
++++1 YES ! Please...

And it works for me; well; it works for the 29 line module attached :-)

In the end though; there is a bit of discussion possible about the
OK/DECLINE meaning; and wether other modules should _know_ about
the fact that their headers where tinkered with.

The other thing; one could argue that one needs both a incomingRQ
header filter, and an outgoing one. :-) but you can do that anyway
with the fixup pass. :-)

Dw.


http://ewse.ceo.org                         http://enrm.ceo.org
DWvGulik@Dialis.xs4all.nl                  Dirk.vanGulik@jrc.it
+39 332 78 0014                                 +39 332 78 9549
                                            fax +39 332 78 9185

ISEI/ESBA;                     The Center For Earth Observation
Joint Research Centre of the European Communities, Ispra, Italy

On Fri, 3 Jan 1997, Ben Laurie wrote:

> Here's the patch to add an extra API for header parsing. As you can see, its
> pretty simple. I've only added it to the main request processor, and not to the
> subrequest processors, on the grounds that the headers from the client only
> happen in the main request. There is room for debate here, though.
> 
> I've tested it lightly, and BrowserMatch still works, so I guess its mostly OK.
> I'd like to commit it so people can test it easily - if its OK then I'll do the
> changes for mod_auth to make it user BrowserMatch instead. I will undertake to
> remove the changes if, in the end, the mod is not approved.
> 
> Cheers,
> 
> Ben.
> 
> Index: http_config.c
> ===================================================================
> RCS file: /export/home/cvs/apache/src/http_config.c,v
> retrieving revision 1.39
> diff -c -r1.39 http_config.c
> *** http_config.c	1997/01/01 18:10:16	1.39
> --- http_config.c	1997/01/03 17:03:08
> ***************
> *** 292,297 ****
> --- 292,301 ----
>      return run_method (r, XtOffsetOf (module, logger), 1);
>   }
>   
> + int header_parse (request_rec *r) {
> +     return run_method (r, XtOffsetOf (module, header_parser), 1);
> + }
> + 
>   /* Auth stuff --- anything that defines one of these will presumably
>    * want to define something for the other.  Note that check_auth is
>    * separate from check_access to make catching some config errors easier.
> Index: http_config.h
> ===================================================================
> RCS file: /export/home/cvs/apache/src/http_config.h,v
> retrieving revision 1.26
> diff -c -r1.26 http_config.h
> *** http_config.h	1997/01/01 18:10:17	1.26
> --- http_config.h	1997/01/03 17:03:14
> ***************
> *** 216,221 ****
> --- 216,222 ----
>       int (*type_checker)(request_rec *);
>       int (*fixer_upper)(request_rec *);
>       int (*logger)(request_rec *);
> +     int (*header_parser)(request_rec *);
>   } module;
>   
>   /* Initializer for the first few module slots, which are only
> ***************
> *** 225,231 ****
>    * handle it back-compatibly, or at least signal an error).
>    */
>   
> ! #define MODULE_MAGIC_NUMBER 19961211
>   #define STANDARD_MODULE_STUFF MODULE_MAGIC_NUMBER, -1, __FILE__, NULL
>   
>   /* Generic accessors for other modules to get at their own module-specific
> --- 226,232 ----
>    * handle it back-compatibly, or at least signal an error).
>    */
>   
> ! #define MODULE_MAGIC_NUMBER 19970103
>   #define STANDARD_MODULE_STUFF MODULE_MAGIC_NUMBER, -1, __FILE__, NULL
>   
>   /* Generic accessors for other modules to get at their own module-specific
> ***************
> *** 291,295 ****
> --- 292,297 ----
>   int run_fixups (request_rec *);	/* poke around for other metainfo, etc.... */
>   int invoke_handler (request_rec *);     
>   int log_transaction (request_rec *r);
> + int header_parse (request_rec *);
>   
>   #endif
> Index: http_request.c
> ===================================================================
> RCS file: /export/home/cvs/apache/src/http_request.c,v
> retrieving revision 1.34
> diff -c -r1.34 http_request.c
> *** http_request.c	1997/01/01 18:10:22	1.34
> --- http_request.c	1997/01/03 17:03:23
> ***************
> *** 867,872 ****
> --- 867,877 ----
>           die (access_status, r);
>   	return;
>       }	
> + 
> +     if ((access_status = header_parse (r))) {
> +         die (access_status, r);
> + 	return;
> +     }
>       
>       switch (satisfies(r)) {
>       case SATISFY_ALL:
> Index: mod_browser.c
> ===================================================================
> RCS file: /export/home/cvs/apache/src/mod_browser.c,v
> retrieving revision 1.6
> diff -c -r1.6 mod_browser.c
> *** mod_browser.c	1997/01/01 18:10:29	1.6
> --- mod_browser.c	1997/01/03 17:03:24
> ***************
> *** 138,144 ****
>   { NULL },
>   };
>   
> ! int fixup_browser_module(request_rec *r)
>   {
>       server_rec *s = r->server;
>       browser_server_config_rec *sconf = get_module_config (s->module_config,
> --- 138,144 ----
>   { NULL },
>   };
>   
> ! int parse_headers_browser_module(request_rec *r)
>   {
>       server_rec *s = r->server;
>       browser_server_config_rec *sconf = get_module_config (s->module_config,
> ***************
> *** 182,187 ****
>      NULL,			/* check auth */
>      NULL,			/* check access */
>      NULL,			/* type_checker */
> !    fixup_browser_module,	/* fixups */
>      NULL,			/* logger */
>   };
> --- 182,188 ----
>      NULL,			/* check auth */
>      NULL,			/* check access */
>      NULL,			/* type_checker */
> !    NULL,			/* fixups */
>      NULL,			/* logger */
> +    parse_headers_browser_module,/* header parser */
>   };
> 
> -- 
> Ben Laurie                Phone: +44 (181) 994 6435  Email: ben@algroup.co.uk
> Freelance Consultant and  Fax:   +44 (181) 994 6472
> Technical Director        URL: http://www.algroup.co.uk/Apache-SSL
> A.L. Digital Ltd,         Apache Group member (http://www.apache.org)
> London, England.          Apache-SSL author
>