httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gst...@apache.org
Subject cvs commit: httpd-2.0/modules/http http_protocol.c
Date Mon, 07 Jan 2002 22:36:15 GMT
gstein      02/01/07 14:36:15

  Modified:    modules/dav/main mod_dav.c
               modules/http http_protocol.c
  Log:
  Fix how mod_dav examines methods in the request -- use the method number
  from the request. To do this, we also need to register all of the new/custom
  methods that mod_dav recognizes.
  
  Note: this fixes a bug where a method (e.g. REPORT) would appear in a
  Limit(Except) directive and Apache would register the method. The method
  number in the request would then be something *other* than M_INVALID, which
  threw off mod_dav's tests.
  
  Submitted by: Sander Striker <striker@apache.org>
  
  Revision  Changes    Path
  1.66      +46 -21    httpd-2.0/modules/dav/main/mod_dav.c
  
  Index: mod_dav.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/dav/main/mod_dav.c,v
  retrieving revision 1.65
  retrieving revision 1.66
  diff -u -r1.65 -r1.66
  --- mod_dav.c	23 Nov 2001 16:35:21 -0000	1.65
  +++ mod_dav.c	7 Jan 2002 22:36:15 -0000	1.66
  @@ -132,12 +132,46 @@
   /* forward-declare for use in configuration lookup */
   extern module DAV_DECLARE_DATA dav_module;
   
  +/* DAV methods */
  +enum {
  +    DAV_M_VERSION_CONTROL = 0,
  +    DAV_M_CHECKOUT,
  +    DAV_M_UNCHECKOUT,
  +    DAV_M_CHECKIN,
  +    DAV_M_UPDATE,
  +    DAV_M_LABEL,
  +    DAV_M_REPORT,
  +    DAV_M_MKWORKSPACE,
  +    DAV_M_MKACTIVITY,
  +    DAV_M_BASELINE_CONTROL,
  +    DAV_M_MERGE,
  +    DAV_M_BIND,
  +    DAV_M_LAST
  +};
  +
  +static int dav_methods[DAV_M_LAST];
  +
   static int dav_init_handler(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp,
                                server_rec *s)
   {
       /* DBG0("dav_init_handler"); */
   
  +    /* Register DAV methods */
  +    dav_methods[DAV_M_VERSION_CONTROL] = ap_method_register(p, "VERSION-CONTROL");
  +    dav_methods[DAV_M_CHECKOUT] = ap_method_register(p, "CHECKOUT");
  +    dav_methods[DAV_M_UNCHECKOUT] = ap_method_register(p, "UNCHECKOUT");
  +    dav_methods[DAV_M_CHECKIN] = ap_method_register(p, "CHECKIN");
  +    dav_methods[DAV_M_UPDATE] = ap_method_register(p, "UPDATE");
  +    dav_methods[DAV_M_LABEL] = ap_method_register(p, "LABEL");
  +    dav_methods[DAV_M_REPORT] = ap_method_register(p, "REPORT");
  +    dav_methods[DAV_M_MKWORKSPACE] = ap_method_register(p, "MKWORKSPACE");
  +    dav_methods[DAV_M_MKACTIVITY] = ap_method_register(p, "MKACTIVITY");
  +    dav_methods[DAV_M_BASELINE_CONTROL] = ap_method_register(p, "BASELINE-CONTROL");
  +    dav_methods[DAV_M_MERGE] = ap_method_register(p, "MERGE");
  +    dav_methods[DAV_M_BIND] = ap_method_register(p, "BIND");
  +
       ap_add_version_component(p, "DAV/2");
  +    
       return OK;
   }
   
  @@ -4479,60 +4513,51 @@
   	return dav_method_unlock(r);
       }
   
  -    /*
  -     * NOTE: When Apache moves creates defines for the add'l DAV methods,
  -     *       then it will no longer use M_INVALID. This code must be
  -     *       updated each time Apache adds method defines.
  -     */
  -    if (r->method_number != M_INVALID) {
  -	return DECLINED;
  -    }
  -
  -    if (!strcmp(r->method, "VERSION-CONTROL")) {
  +    if (r->method_number == dav_methods[DAV_M_VERSION_CONTROL]) {
   	return dav_method_vsn_control(r);
       }
   
  -    if (!strcmp(r->method, "CHECKOUT")) {
  +    if (r->method_number == dav_methods[DAV_M_CHECKOUT]) {
   	return dav_method_checkout(r);
       }
   
  -    if (!strcmp(r->method, "UNCHECKOUT")) {
  +    if (r->method_number == dav_methods[DAV_M_UNCHECKOUT]) {
   	return dav_method_uncheckout(r);
       }
   
  -    if (!strcmp(r->method, "CHECKIN")) {
  +    if (r->method_number == dav_methods[DAV_M_CHECKIN]) {
   	return dav_method_checkin(r);
       }
   
  -    if (!strcmp(r->method, "UPDATE")) {
  +    if (r->method_number == dav_methods[DAV_M_UPDATE]) {
   	return dav_method_update(r);
       }
   
  -    if (!strcmp(r->method, "LABEL")) {
  +    if (r->method_number == dav_methods[DAV_M_LABEL]) {
   	return dav_method_label(r);
       }
   
  -    if (!strcmp(r->method, "REPORT")) {
  +    if (r->method_number == dav_methods[DAV_M_REPORT]) {
   	return dav_method_report(r);
       }
   
  -    if (!strcmp(r->method, "MKWORKSPACE")) {
  +    if (r->method_number == dav_methods[DAV_M_MKWORKSPACE]) {
   	return dav_method_make_workspace(r);
       }
   
  -    if (!strcmp(r->method, "MKACTIVITY")) {
  +    if (r->method_number == dav_methods[DAV_M_MKACTIVITY]) {
   	return dav_method_make_activity(r);
       }
   
  -    if (!strcmp(r->method, "BASELINE-CONTROL")) {
  +    if (r->method_number == dav_methods[DAV_M_BASELINE_CONTROL]) {
   	return dav_method_baseline_control(r);
       }
   
  -    if (!strcmp(r->method, "MERGE")) {
  +    if (r->method_number == dav_methods[DAV_M_MERGE]) {
   	return dav_method_merge(r);
       }
   
  -    if (!strcmp(r->method, "BIND")) {
  +    if (r->method_number == dav_methods[DAV_M_BIND]) {
   	return dav_method_bind(r);
       }
   
  
  
  
  1.385     +14 -6     httpd-2.0/modules/http/http_protocol.c
  
  Index: http_protocol.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/http/http_protocol.c,v
  retrieving revision 1.384
  retrieving revision 1.385
  diff -u -r1.384 -r1.385
  --- http_protocol.c	3 Jan 2002 19:20:54 -0000	1.384
  +++ http_protocol.c	7 Jan 2002 22:36:15 -0000	1.385
  @@ -337,7 +337,7 @@
   
   AP_DECLARE(int) ap_method_register(apr_pool_t *p, const char *methname)
   {
  -    int *newmethnum;
  +    int *methnum;
   
       if (methods_registry == NULL) {
           ap_method_registry_init(p);
  @@ -346,7 +346,15 @@
       if (methname == NULL) {
           return M_INVALID;
       }
  -
  +    
  +    /* Check if the method was previously registered.  If it was
  +     * return the associated method number.
  +     */
  +    methnum = (int *)apr_hash_get(methods_registry, methname,
  +                                  APR_HASH_KEY_STRING);
  +    if (methnum != NULL)
  +        return *methnum;
  +        
       if (cur_method_number > METHOD_NUMBER_LAST) {
           /* The method registry  has run out of dynamically
            * assignable method numbers. Log this and return M_INVALID.
  @@ -358,11 +366,11 @@
           return M_INVALID;
       }
   
  -    newmethnum  = (int*)apr_palloc(p, sizeof(int));
  -    *newmethnum = cur_method_number++;
  -    apr_hash_set(methods_registry, methname, APR_HASH_KEY_STRING, newmethnum);
  +    methnum = (int *)apr_palloc(p, sizeof(int));
  +    *methnum = cur_method_number++;
  +    apr_hash_set(methods_registry, methname, APR_HASH_KEY_STRING, methnum);
   
  -    return *newmethnum;
  +    return *methnum;
   }
   
   /* Get the method number associated with the given string, assumed to
  
  
  

Mime
View raw message