resolve a request URI to a resource descriptor. * * If label_allowed != 0, then allow the request target to be altered by * a Label: header. * * If use_checked_in is true, then the repository provider should return * the resource identified by the DAV:checked-in property of the resource * identified by the Request-URI. */
| 766 | * identified by the Request-URI. |
| 767 | */ |
| 768 | DAV_DECLARE(dav_error *) dav_get_resource(request_rec *r, int label_allowed, |
| 769 | int use_checked_in, dav_resource **res_p) |
| 770 | { |
| 771 | dav_dir_conf *conf; |
| 772 | const char *label = NULL, *base; |
| 773 | dav_error *err; |
| 774 | |
| 775 | /* if the request target can be overridden, get any target selector */ |
| 776 | if (label_allowed) { |
| 777 | label = apr_table_get(r->headers_in, "label"); |
| 778 | } |
| 779 | |
| 780 | conf = ap_get_module_config(r->per_dir_config, &dav_module); |
| 781 | /* assert: conf->provider != NULL */ |
| 782 | if (conf->provider == NULL) { |
| 783 | return dav_new_error(r->pool, HTTP_METHOD_NOT_ALLOWED, 0, 0, |
| 784 | apr_psprintf(r->pool, |
| 785 | "DAV not enabled for %s", |
| 786 | ap_escape_html(r->pool, r->uri))); |
| 787 | } |
| 788 | |
| 789 | /* Take the repos root from DAVBasePath if configured, else the |
| 790 | * path of the enclosing section. */ |
| 791 | base = conf->base ? conf->base : conf->dir; |
| 792 | |
| 793 | /* resolve the resource */ |
| 794 | err = (*conf->provider->repos->get_resource)(r, base, |
| 795 | label, use_checked_in, |
| 796 | res_p); |
| 797 | if (err != NULL) { |
| 798 | /* In the error path, give a hint that DavBasePath needs to be |
| 799 | * used if the location was configured via a regex match. */ |
| 800 | if (!conf->base) { |
| 801 | core_dir_config *cdc = ap_get_core_module_config(r->per_dir_config); |
| 802 | |
| 803 | if (cdc->r) { |
| 804 | ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL, APLOGNO(10484) |
| 805 | "failed to find repository for location configured " |
| 806 | "via regex match - missing DAVBasePath?"); |
| 807 | } |
| 808 | } |
| 809 | |
| 810 | err = dav_push_error(r->pool, err->status, 0, |
| 811 | "Could not fetch resource information.", err); |
| 812 | return err; |
| 813 | } |
| 814 | |
| 815 | /* Note: this shouldn't happen, but just be sure... */ |
| 816 | if (*res_p == NULL) { |
| 817 | /* ### maybe use HTTP_INTERNAL_SERVER_ERROR */ |
| 818 | return dav_new_error(r->pool, HTTP_NOT_FOUND, 0, 0, |
| 819 | apr_psprintf(r->pool, |
| 820 | "The provider did not define a " |
| 821 | "resource for %s.", |
| 822 | ap_escape_html(r->pool, r->uri))); |
| 823 | } |
| 824 | |
| 825 | /* ### hmm. this doesn't feel like the right place or thing to do */ |
no test coverage detected