Based on my interpretation of the RFC, I think this might be
a better way to handle the body case for MKCOL. I sort of
think this is what they were thinking rather than relying
on the request entity headers.
Thoughts? -- justin
Index: modules/dav/main/mod_dav.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/dav/main/mod_dav.c,v
retrieving revision 1.79
diff -u -r1.79 mod_dav.c
--- modules/dav/main/mod_dav.c 17 May 2002 11:33:08 -0000 1.79
+++ modules/dav/main/mod_dav.c 2 Jun 2002 23:24:55 -0000
@@ -2289,60 +2289,25 @@
return DONE;
}
-static int process_mkcol_body(request_rec *r)
+static int verify_mkcol_body(request_rec *r)
{
- /* This is snarfed from ap_setup_client_block(). We could get pretty
- * close to this behavior by passing REQUEST_NO_BODY, but we need to
- * return HTTP_UNSUPPORTED_MEDIA_TYPE (while ap_setup_client_block
- * returns HTTP_REQUEST_ENTITY_TOO_LARGE). */
-
- const char *tenc = apr_table_get(r->headers_in, "Transfer-Encoding");
- const char *lenp = apr_table_get(r->headers_in, "Content-Length");
-
- /* make sure to set the Apache request fields properly. */
- r->read_body = REQUEST_NO_BODY;
- r->read_chunked = 0;
- r->remaining = 0;
-
- if (tenc) {
- if (strcasecmp(tenc, "chunked")) {
- /* Use this instead of Apache's default error string */
- ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
- "Unknown Transfer-Encoding %s", tenc);
- return HTTP_NOT_IMPLEMENTED;
- }
-
- r->read_chunked = 1;
- }
- else if (lenp) {
- const char *pos = lenp;
-
- while (apr_isdigit(*pos) || apr_isspace(*pos)) {
- ++pos;
- }
-
- if (*pos != '\0') {
- /* This supplies additional information for the default message. */
- ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
- "Invalid Content-Length %s", lenp);
- return HTTP_BAD_REQUEST;
- }
-
- r->remaining = atol(lenp);
- }
-
- if (r->read_chunked || r->remaining > 0) {
- /* ### log something? */
+ /* MKCOL portion of the RFC specifies that if the server can't handle
+ * the type, we must return HTTP_UNSUPPORTED_MEDIA_TYPE.
+ *
+ * If someone were to post data without a Content-Type, it'll
+ * get ignored. If the request is still too large for us to
+ * handle, the filters will return HTTP_REQUEST_ENTITY_TOO_LARGE.
+ */
+ const char *ct = apr_table_get(r->headers_in, "Content-Type");
- /* Apache will supply a default error for this. */
+ /* We don't support ANY content-types at this time.
+ * Let the core supply the default error for this.
+ */
+ if (ct) {
return HTTP_UNSUPPORTED_MEDIA_TYPE;
}
- /*
- * Get rid of the body. this will call ap_setup_client_block(), but
- * our copy above has already verified its work.
- */
- return ap_discard_request_body(r);
+ return OK;
}
/* handle the MKCOL method */
@@ -2359,8 +2324,7 @@
dav_response *multi_status;
/* handle the request body */
- /* ### this may move lower once we start processing bodies */
- if ((result = process_mkcol_body(r)) != OK) {
+ if ((result = verify_mkcol_body(r)) != OK) {
return result;
}