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/dav/main mod_dav.c mod_dav.h
Date Mon, 05 Feb 2001 12:34:46 GMT
gstein      01/02/05 04:34:45

  Modified:    modules/dav/main mod_dav.c mod_dav.h
  Log:
  *) add activity handling: OPTIONS and MKACTIVITY
  *) fix HTTP status code in MKWORKSPACE handling
  *) add can_be_activity and make_activity hooks to dav_hooks_vsn
  
  Revision  Changes    Path
  1.42      +56 -3     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.41
  retrieving revision 1.42
  diff -u -u -r1.41 -r1.42
  --- mod_dav.c	2001/01/26 11:44:49	1.41
  +++ mod_dav.c	2001/02/05 12:34:37	1.42
  @@ -1672,6 +1672,10 @@
               if (vsn_hooks->can_be_workspace != NULL
                   && (*vsn_hooks->can_be_workspace)(resource))
                   apr_table_addn(methods, "MKWORKSPACE", "");
  +
  +            if (vsn_hooks->can_be_activity != NULL
  +                && (*vsn_hooks->can_be_activity)(resource))
  +                apr_table_addn(methods, "MKACTIVITY", "");
           }
           else if (!resource->versioned) {
               if ((*vsn_hooks->versionable)(resource))
  @@ -3930,7 +3934,7 @@
   
       /* attempt to create the workspace */
       if ((err = (*vsn_hooks->make_workspace)(resource, doc)) != NULL) {
  -	err = dav_push_error(r->pool, HTTP_CONFLICT, 0,
  +	err = dav_push_error(r->pool, err->status, 0,
   			     apr_psprintf(r->pool,
   					 "Could not create workspace %s.",
   					 ap_escape_html(r->pool, r->uri)),
  @@ -3947,8 +3951,57 @@
   
   static int dav_method_make_activity(request_rec *r)
   {
  -    /* ### */
  -    return HTTP_METHOD_NOT_ALLOWED;
  +    dav_resource *resource;
  +    const dav_hooks_vsn *vsn_hooks = DAV_GET_HOOKS_VSN(r);
  +    dav_error *err;
  +    int result;
  +
  +    /* if no versioning provider, or the provider does not support activities,
  +     * decline the request
  +     */
  +    if (vsn_hooks == NULL || vsn_hooks->make_activity == NULL)
  +        return DECLINED;
  +
  +    /* ask repository module to resolve the resource */
  +    err = dav_get_resource(r, 0 /*target_allowed*/, NULL, &resource);
  +    if (err != NULL)
  +        return dav_handle_err(r, err, NULL);
  +
  +    /* MKACTIVITY does not have a defined request body. */
  +    if ((result = ap_discard_request_body(r)) != OK) {
  +	return result;
  +    }
  +
  +    /* Check request preconditions */
  +
  +    /* ### need a general mechanism for reporting precondition violations
  +     * ### (should be returning XML document for 403/409 responses)
  +     */
  +
  +    /* resource must not already exist */
  +    if (resource->exists) {
  +        err = dav_new_error(r->pool, HTTP_CONFLICT, 0,
  +                            "<DAV:resource-must-be-null/>");
  +	return dav_handle_err(r, err, NULL);
  +    }
  +
  +    /* ### what about locking? */
  +
  +    /* attempt to create the activity */
  +    if ((err = (*vsn_hooks->make_activity)(resource)) != NULL) {
  +	err = dav_push_error(r->pool, err->status, 0,
  +			     apr_psprintf(r->pool,
  +					 "Could not create activity %s.",
  +					 ap_escape_html(r->pool, r->uri)),
  +			     err);
  +        return dav_handle_err(r, err, NULL);
  +    }
  +
  +    /* set the Cache-Control header, per the spec */
  +    apr_table_setn(r->headers_out, "Cache-Control", "no-cache");
  +
  +    /* return an appropriate response (HTTP_CREATED) */
  +    return dav_created(r, resource->uri, "Activity", 0 /*replaced*/);
   }
   
   static int dav_method_baseline_control(request_rec *r)
  
  
  
  1.40      +22 -0     httpd-2.0/modules/dav/main/mod_dav.h
  
  Index: mod_dav.h
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/dav/main/mod_dav.h,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -u -r1.39 -r1.40
  --- mod_dav.h	2001/01/26 11:44:49	1.39
  +++ mod_dav.h	2001/02/05 12:34:39	1.40
  @@ -2063,6 +2063,28 @@
       */
       dav_error * (*make_workspace)(dav_resource *resource,
                                     ap_xml_doc *doc);
  +
  +    /*
  +    ** Determine whether a null resource can be created as an activity.
  +    ** The provider may restrict activities to certain locations.
  +    ** Returns 0 if the resource cannot be an activity.
  +    **
  +    ** This hook is optional; if the provider does not support activities,
  +    ** it should be set to NULL.
  +    */
  +    int (*can_be_activity)(const dav_resource *resource);
  +
  +    /*
  +    ** Create an activity resource. The resource must not already
  +    ** exist.
  +    **
  +    ** If activity creation is succesful, the state of the resource
  +    ** object is updated appropriately.
  +    **
  +    ** This hook is optional; if the provider does not support activities,
  +    ** it should be set to NULL.
  +    */
  +    dav_error * (*make_activity)(dav_resource *resource);
   };
   
   
  
  
  

Mime
View raw message