handy function for return values of methods that (may) create things. * locn if provided is assumed to be escaped. */
| 678 | /* handy function for return values of methods that (may) create things. |
| 679 | * locn if provided is assumed to be escaped. */ |
| 680 | static int dav_created(request_rec *r, const char *locn, const char *what, |
| 681 | int replaced) |
| 682 | { |
| 683 | const char *body; |
| 684 | |
| 685 | if (locn == NULL) { |
| 686 | locn = ap_escape_uri(r->pool, r->uri); |
| 687 | } |
| 688 | |
| 689 | /* did the target resource already exist? */ |
| 690 | if (replaced) { |
| 691 | /* Apache will supply a default message */ |
| 692 | return HTTP_NO_CONTENT; |
| 693 | } |
| 694 | |
| 695 | /* Per HTTP/1.1, S10.2.2: add a Location header to contain the |
| 696 | * URI that was created. */ |
| 697 | |
| 698 | /* Convert locn to an absolute URI, and return in Location header */ |
| 699 | apr_table_setn(r->headers_out, "Location", ap_construct_url(r->pool, locn, r)); |
| 700 | |
| 701 | /* ### insert an ETag header? see HTTP/1.1 S10.2.2 */ |
| 702 | |
| 703 | /* Apache doesn't allow us to set a variable body for HTTP_CREATED, so |
| 704 | * we must manufacture the entire response. */ |
| 705 | body = apr_pstrcat(r->pool, what, " ", ap_escape_html(r->pool, locn), |
| 706 | " has been created.", NULL); |
| 707 | return dav_error_response(r, HTTP_CREATED, body); |
| 708 | } |
| 709 | |
| 710 | /* ### move to dav_util? */ |
| 711 | DAV_DECLARE(int) dav_get_depth(request_rec *r, int def_depth) |
no test coverage detected