Apache-DAV
view release on metacpan or search on metacpan
mod_dav-1.0.3.patch view on Meta::CPAN
--- ./mod_dav.c Sun Sep 23 00:22:39 2001
+++ /usr/msrc/cvs/mod_dav/mod_dav.c Fri Mar 15 23:45:29 2002
@@ -764,7 +764,7 @@
}
/* resolve a request URI to a resource descriptor */
-static int dav_get_resource(request_rec *r, dav_resource **res_p)
+/* ### static */ int dav_get_resource(request_rec *r, dav_resource **res_p)
{
dav_dir_conf *conf;
const dav_hooks_repository *repos_hooks;
@@ -794,7 +794,7 @@
return OK;
}
-static dav_error * dav_open_lockdb(request_rec *r, int ro, dav_lockdb **lockdb)
+/* ### static */ dav_error * dav_open_lockdb(request_rec *r, int ro, dav_lockdb **lockdb)
{
const dav_hooks_locks *hooks = DAV_GET_HOOKS_LOCKS(r);
@@ -1919,20 +1919,132 @@
return 0;
}
+/* process PROPPATCH */
+int dav_proppatch(request_rec *r, dav_resource *resource, dav_xml_doc *doc, dav_text **propstat_text_ptr)
+{
+ dav_error *err;
+ int result;
+ dav_xml_elem *child;
+ dav_propdb *propdb;
+ int failure = 0;
+ dav_text *propstat_text;
+ array_header *ctx_list;
+ dav_prop_ctx *ctx;
+
+ *propstat_text_ptr = NULL ;
+
+ if (doc == NULL || !dav_validate_root(doc, "propertyupdate")) {
+ /* This supplies additional information for the default message. */
+ ap_log_rerror(APLOG_MARK, APLOG_ERR | APLOG_NOERRNO, r,
+ "The request body does not contain "
+ "a \"propertyupdate\" element.");
+ return HTTP_BAD_REQUEST;
+ }
+
+ /* Check If-Headers and existing locks */
+ /* Note: depth == 0. Implies no need for a multistatus response. */
+ if ((err = dav_validate_request(r, resource, 0, NULL, NULL,
+ DAV_VALIDATE_RESOURCE, NULL)) != NULL) {
+ /* ### add a higher-level description? */
+ return dav_handle_err(r, err, NULL);
+ }
+
+ if ((err = dav_open_propdb(r, NULL, resource, 0, doc->namespaces,
+ &propdb)) != NULL) {
+ err = dav_push_error(r->pool, HTTP_INTERNAL_SERVER_ERROR, 0,
+ ap_psprintf(r->pool,
+ "Could not open the property "
+ "database for %s.",
+ ap_escape_html(r->pool, r->uri)),
+ err);
+ return dav_handle_err(r, err, NULL);
+ }
+ /* ### what to do about closing the propdb on server failure? */
+
+ /* ### validate "live" properties */
+
+ /* set up an array to hold property operation contexts */
+ ctx_list = ap_make_array(r->pool, 10, sizeof(dav_prop_ctx));
+
+ /* do a first pass to ensure that all "remove" properties exist */
+ for (child = doc->root->first_child; child; child = child->next) {
+ int is_remove;
+ dav_xml_elem *prop_group;
+ dav_xml_elem *one_prop;
+
+ /* Ignore children that are not set/remove */
+ if (child->ns != DAV_NS_DAV_ID
+ || (!(is_remove = strcmp(child->name, "remove") == 0)
+ && strcmp(child->name, "set") != 0)) {
+ continue;
+ }
+
+ /* make sure that a "prop" child exists for set/remove */
+ if ((prop_group = dav_find_child(child, "prop")) == NULL) {
+ dav_close_propdb(propdb);
+
+ /* This supplies additional information for the default message. */
+ ap_log_rerror(APLOG_MARK, APLOG_ERR | APLOG_NOERRNO, r,
+ "A \"prop\" element is missing inside "
+ "the propertyupdate command.");
+ return HTTP_BAD_REQUEST;
+ }
+
+ for (one_prop = prop_group->first_child; one_prop;
+ one_prop = one_prop->next) {
+
+ ctx = (dav_prop_ctx *)ap_push_array(ctx_list);
+ ctx->propdb = propdb;
+ ctx->operation = is_remove ? DAV_PROP_OP_DELETE : DAV_PROP_OP_SET;
+ ctx->prop = one_prop;
+
+ ctx->r = r; /* for later use by dav_prop_log_errors() */
+
+ dav_prop_validate(ctx);
+
+ if ( DAV_PROP_CTX_HAS_ERR(*ctx) ) {
+ failure = 1;
+ }
+ }
+ }
+
+ /* ### should test that we found at least one set/remove */
+
+ /* execute all of the operations */
+ if (!failure && dav_process_ctx_list(dav_prop_exec, ctx_list, 1, 0)) {
+ failure = 1;
+ }
+
+ /* generate a failure/success response */
mod_dav-1.0.3.patch view on Meta::CPAN
+ else {
+ (void)dav_process_ctx_list(dav_prop_commit, ctx_list, 0, 0);
+ propstat_text = dav_success_proppatch(r->pool, ctx_list);
+ }
+
+ /* make sure this gets closed! */
+ dav_close_propdb(propdb);
+
+ /* log any errors that occurred */
+ (void)dav_process_ctx_list(dav_prop_log_errors, ctx_list, 0, 0);
+
+ *propstat_text_ptr = propstat_text;
+
+ return OK ;
+}
+
+
/* handle the PROPPATCH method */
static int dav_method_proppatch(request_rec *r)
{
- dav_error *err;
dav_resource *resource;
int result;
dav_xml_doc *doc;
- dav_xml_elem *child;
- dav_propdb *propdb;
- int failure = 0;
dav_response resp = { 0 };
dav_text *propstat_text;
- array_header *ctx_list;
- dav_prop_ctx *ctx;
/* Ask repository module to resolve the resource */
result = dav_get_resource(r, &resource);
@@ -1948,103 +2060,9 @@
}
/* note: doc == NULL if no request body */
- if (doc == NULL || !dav_validate_root(doc, "propertyupdate")) {
- /* This supplies additional information for the default message. */
- ap_log_rerror(APLOG_MARK, APLOG_ERR | APLOG_NOERRNO, r,
- "The request body does not contain "
- "a \"propertyupdate\" element.");
- return HTTP_BAD_REQUEST;
- }
-
- /* Check If-Headers and existing locks */
- /* Note: depth == 0. Implies no need for a multistatus response. */
- if ((err = dav_validate_request(r, resource, 0, NULL, NULL,
- DAV_VALIDATE_RESOURCE, NULL)) != NULL) {
- /* ### add a higher-level description? */
- return dav_handle_err(r, err, NULL);
- }
-
- if ((err = dav_open_propdb(r, NULL, resource, 0, doc->namespaces,
- &propdb)) != NULL) {
- err = dav_push_error(r->pool, HTTP_INTERNAL_SERVER_ERROR, 0,
- ap_psprintf(r->pool,
- "Could not open the property "
- "database for %s.",
- ap_escape_html(r->pool, r->uri)),
- err);
- return dav_handle_err(r, err, NULL);
- }
- /* ### what to do about closing the propdb on server failure? */
-
- /* ### validate "live" properties */
-
- /* set up an array to hold property operation contexts */
- ctx_list = ap_make_array(r->pool, 10, sizeof(dav_prop_ctx));
-
- /* do a first pass to ensure that all "remove" properties exist */
- for (child = doc->root->first_child; child; child = child->next) {
- int is_remove;
- dav_xml_elem *prop_group;
- dav_xml_elem *one_prop;
-
- /* Ignore children that are not set/remove */
- if (child->ns != DAV_NS_DAV_ID
- || (!(is_remove = strcmp(child->name, "remove") == 0)
- && strcmp(child->name, "set") != 0)) {
- continue;
- }
-
- /* make sure that a "prop" child exists for set/remove */
- if ((prop_group = dav_find_child(child, "prop")) == NULL) {
- dav_close_propdb(propdb);
-
- /* This supplies additional information for the default message. */
- ap_log_rerror(APLOG_MARK, APLOG_ERR | APLOG_NOERRNO, r,
- "A \"prop\" element is missing inside "
- "the propertyupdate command.");
- return HTTP_BAD_REQUEST;
- }
-
- for (one_prop = prop_group->first_child; one_prop;
- one_prop = one_prop->next) {
-
- ctx = (dav_prop_ctx *)ap_push_array(ctx_list);
- ctx->propdb = propdb;
- ctx->operation = is_remove ? DAV_PROP_OP_DELETE : DAV_PROP_OP_SET;
- ctx->prop = one_prop;
-
- ctx->r = r; /* for later use by dav_prop_log_errors() */
-
- dav_prop_validate(ctx);
-
- if ( DAV_PROP_CTX_HAS_ERR(*ctx) ) {
- failure = 1;
- }
- }
- }
-
- /* ### should test that we found at least one set/remove */
-
- /* execute all of the operations */
- if (!failure && dav_process_ctx_list(dav_prop_exec, ctx_list, 1, 0)) {
- failure = 1;
- }
-
- /* generate a failure/success response */
( run in 0.624 second using v1.01-cache-2.11-cpan-a49fcb8fa48 )