httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@locus.apache.org
Subject cvs commit: apache-2.0/src/main http_protocol.c http_request.c
Date Thu, 10 Aug 2000 11:22:59 GMT
coar        00/08/10 04:22:58

  Modified:    src      CHANGES
               src/include http_request.h httpd.h
               src/main http_protocol.c http_request.c
  Log:
  	Add support for arbitrary extension methods for the Allow
  	response header field, and an API routine for modifying the
  	allowed list in a unified manner for both known and extension
  	methods.
  
  Revision  Changes    Path
  1.197     +4 -0      apache-2.0/src/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/CHANGES,v
  retrieving revision 1.196
  retrieving revision 1.197
  diff -u -u -r1.196 -r1.197
  --- CHANGES	2000/08/09 20:47:05	1.196
  +++ CHANGES	2000/08/10 11:22:54	1.197
  @@ -1,4 +1,8 @@
   Changes with Apache 2.0a6
  +  *) Add support for extension methods for the Allow response header
  +     field, and an API routine for accessing r->allowed and the
  +     list of extension methods in a unified manner.  [Ken Coar]
  +
     *) mod_cern_meta: fix broken file reading loop in scan_meta_file().
        [Rob Simonson <simo@us.ibm.com>]
   
  
  
  
  1.14      +17 -1     apache-2.0/src/include/http_request.h
  
  Index: http_request.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/include/http_request.h,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -u -r1.13 -r1.14
  --- http_request.h	2000/08/02 05:25:29	1.13
  +++ http_request.h	2000/08/10 11:22:55	1.14
  @@ -106,7 +106,23 @@
   API_EXPORT(int) ap_some_auth_required(request_rec *r);
   API_EXPORT(int) ap_is_initial_req(request_rec *r);
   API_EXPORT(void) ap_update_mtime(request_rec *r, apr_time_t dependency_mtime);
  -
  +/**
  + * Add one or more methods to the list permitted to access the resource.
  + * Usually executed by the content handler before the response header is
  + * sent, but sometimes invoked at an earlier phase if a module knows it
  + * can set the list authoritatively.  Note that the methods are ADDED
  + * to any already permitted unless the reset flag is non-zero.  The
  + * list is used to generate the Allow response header field when it
  + * is needed.
  + * @param   r     The pointer to the request identifying the resource.
  + * @param   reset Boolean flag indicating whether this list should
  + *                completely replace any current settings.
  + * @param   ...   A NULL-terminated list of strings, each identifying a
  + *                method name to add.
  + * @return  None.
  + * @deffunc void ap_allow_methods(request_rec *r, int reset, ...)
  + */
  +API_EXPORT(void) ap_allow_methods(request_rec *r, int reset, ...);
   #ifdef CORE_PRIVATE
   /* Function called by main.c to handle first-level request */
   void ap_process_request(request_rec *);
  
  
  
  1.73      +1 -0      apache-2.0/src/include/httpd.h
  
  Index: httpd.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/include/httpd.h,v
  retrieving revision 1.72
  retrieving revision 1.73
  diff -u -u -r1.72 -r1.73
  --- httpd.h	2000/08/10 11:07:26	1.72
  +++ httpd.h	2000/08/10 11:22:55	1.73
  @@ -666,6 +666,7 @@
        *  handler can't be installed by mod_actions. </PRE>
        */
       int allowed;		/* Allowed methods - for 405, OPTIONS, etc */
  +    apr_array_header_t *allowed_xmethods; /* Array of extension methods */
   
       /** byte count in stream is for body */
       int sent_bodyct;
  
  
  
  1.102     +35 -17    apache-2.0/src/main/http_protocol.c
  
  Index: http_protocol.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/main/http_protocol.c,v
  retrieving revision 1.101
  retrieving revision 1.102
  diff -u -u -r1.101 -r1.102
  --- http_protocol.c	2000/08/06 06:07:34	1.101
  +++ http_protocol.c	2000/08/10 11:22:56	1.102
  @@ -1572,23 +1572,41 @@
    */
   static char *make_allow(request_rec *r)
   {
  -    return 2 + apr_pstrcat(r->pool,
  -                   (r->allowed & (1 << M_GET))       ? ", GET, HEAD" : "",
  -                   (r->allowed & (1 << M_POST))      ? ", POST"      : "",
  -                   (r->allowed & (1 << M_PUT))       ? ", PUT"       : "",
  -                   (r->allowed & (1 << M_DELETE))    ? ", DELETE"    : "",
  -                   (r->allowed & (1 << M_CONNECT))   ? ", CONNECT"   : "",
  -                   (r->allowed & (1 << M_OPTIONS))   ? ", OPTIONS"   : "",
  -                   (r->allowed & (1 << M_PATCH))     ? ", PATCH"     : "",
  -                   (r->allowed & (1 << M_PROPFIND))  ? ", PROPFIND"  : "",
  -                   (r->allowed & (1 << M_PROPPATCH)) ? ", PROPPATCH" : "",
  -                   (r->allowed & (1 << M_MKCOL))     ? ", MKCOL"     : "",
  -                   (r->allowed & (1 << M_COPY))      ? ", COPY"      : "",
  -                   (r->allowed & (1 << M_MOVE))      ? ", MOVE"      : "",
  -                   (r->allowed & (1 << M_LOCK))      ? ", LOCK"      : "",
  -                   (r->allowed & (1 << M_UNLOCK))    ? ", UNLOCK"    : "",
  -                   ", TRACE",
  -                   NULL);
  +    char *list;
  +
  +    list = apr_pstrcat(r->pool,
  +		       (r->allowed & (1 << M_GET))       ? ", GET, HEAD" : "",
  +		       (r->allowed & (1 << M_POST))      ? ", POST"      : "",
  +		       (r->allowed & (1 << M_PUT))       ? ", PUT"       : "",
  +		       (r->allowed & (1 << M_DELETE))    ? ", DELETE"    : "",
  +		       (r->allowed & (1 << M_CONNECT))   ? ", CONNECT"   : "",
  +		       (r->allowed & (1 << M_OPTIONS))   ? ", OPTIONS"   : "",
  +		       (r->allowed & (1 << M_PATCH))     ? ", PATCH"     : "",
  +		       (r->allowed & (1 << M_PROPFIND))  ? ", PROPFIND"  : "",
  +		       (r->allowed & (1 << M_PROPPATCH)) ? ", PROPPATCH" : "",
  +		       (r->allowed & (1 << M_MKCOL))     ? ", MKCOL"     : "",
  +		       (r->allowed & (1 << M_COPY))      ? ", COPY"      : "",
  +		       (r->allowed & (1 << M_MOVE))      ? ", MOVE"      : "",
  +		       (r->allowed & (1 << M_LOCK))      ? ", LOCK"      : "",
  +		       (r->allowed & (1 << M_UNLOCK))    ? ", UNLOCK"    : "",
  +		       ", TRACE",
  +		       NULL);
  +    if ((r->allowed & (1 << M_INVALID)) && (r->allowed_xmethods->nelts))
{
  +	int i;
  +	char **xmethod = (char **) r->allowed_xmethods->elts;
  +
  +	/*
  +	 * Append all of the elements of r->allowed_xmethods
  +	 */
  +	for (i = 0; i < r->allowed_xmethods->nelts; ++i) {
  +	    list = ap_pstrcat(r->pool, list, ", ", xmethod[i], NULL);
  +	}
  +    }
  +    /*
  +     * Space past the leading ", ".  Wastes two bytes, but that's better
  +     * than futzing around to find the actual length.
  +     */
  +    return list + 2;
   }
   
   API_EXPORT(int) ap_send_http_trace(request_rec *r)
  
  
  
  1.40      +46 -0     apache-2.0/src/main/http_request.c
  
  Index: http_request.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/main/http_request.c,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -u -r1.39 -r1.40
  --- http_request.c	2000/08/06 06:07:35	1.39
  +++ http_request.c	2000/08/10 11:22:57	1.40
  @@ -79,6 +79,9 @@
   #include "apr_strings.h"
   #include "apr_file_io.h"
   #include "apr_fnmatch.h"
  +#ifdef APR_HAVE_STDARG_H
  +#include <stdarg.h>
  +#endif
   
   AP_HOOK_STRUCT(
   	    AP_HOOK_LINK(translate_name)
  @@ -1423,5 +1426,48 @@
   {
       if (r->mtime < dependency_mtime) {
   	r->mtime = dependency_mtime;
  +    }
  +}
  +
  +API_EXPORT(void) ap_allow_methods(request_rec *r, int reset, ...) {
  +    int mnum;
  +    const char *method;
  +    const char **xmethod;
  +    va_list methods;
  +
  +    /*
  +     * Get rid of any current settings if requested; not just the
  +     * well-known methods but any extensions as well.
  +     */
  +    if (reset) {
  +	r->allowed = 0;
  +	if (r->allowed_xmethods != NULL) {
  +	    r->allowed_xmethods->nelts = 0;
  +	}
  +    }
  +
  +    va_start(methods, reset);
  +    while ((method = va_arg(methods, const char *)) != NULL) {
  +	/*
  +	 * Look up our internal number for this particular method.
  +	 * Even if it isn't one of the ones we know about, the return
  +	 * value is used in the same way.
  +	 */
  +	mnum = ap_method_number_of(method);
  +	r->allowed |= (1 << mnum);
  +	/*
  +	 * Now, if we don't know about it, we regard it as an
  +	 * extension method.  Add it to our array of such.  This means
  +	 * that anything that checks for M_INVALID needs to make an
  +	 * additional check of this array if it *is* invalid.
  +	 */
  +	if (mnum == M_INVALID) {
  +	    if (r->allowed_xmethods == NULL) {
  +		r->allowed_xmethods = apr_make_array(r->pool, 2,
  +						     sizeof(char *));
  +	    }
  +	    xmethod = (const char **) apr_push_array(r->allowed_xmethods);
  +	    *xmethod = method;
  +	}
       }
   }
  
  
  

Mime
View raw message