handle the GET method */
| 901 | |
| 902 | /* handle the GET method */ |
| 903 | static int dav_method_get(request_rec *r) |
| 904 | { |
| 905 | dav_resource *resource; |
| 906 | dav_error *err; |
| 907 | int status; |
| 908 | |
| 909 | /* This method should only be called when the resource is not |
| 910 | * visible to Apache. We will fetch the resource from the repository, |
| 911 | * then create a subrequest for Apache to handle. |
| 912 | */ |
| 913 | err = dav_get_resource(r, 1 /* label_allowed */, 0 /* use_checked_in */, |
| 914 | &resource); |
| 915 | if (err != NULL) |
| 916 | return dav_handle_err(r, err, NULL); |
| 917 | |
| 918 | /* check for any method preconditions */ |
| 919 | if (dav_run_method_precondition(r, resource, NULL, NULL, &err) != DECLINED |
| 920 | && err) { |
| 921 | return dav_handle_err(r, err, NULL); |
| 922 | } |
| 923 | |
| 924 | if (!resource->exists) { |
| 925 | /* Apache will supply a default error for this. */ |
| 926 | return HTTP_NOT_FOUND; |
| 927 | } |
| 928 | |
| 929 | /* set up the HTTP headers for the response */ |
| 930 | if ((err = (*resource->hooks->set_headers)(r, resource)) != NULL) { |
| 931 | err = dav_push_error(r->pool, err->status, 0, |
| 932 | "Unable to set up HTTP headers.", |
| 933 | err); |
| 934 | return dav_handle_err(r, err, NULL); |
| 935 | } |
| 936 | |
| 937 | /* Handle conditional requests */ |
| 938 | status = ap_meets_conditions(r); |
| 939 | if (status) { |
| 940 | return status; |
| 941 | } |
| 942 | |
| 943 | if (r->header_only) { |
| 944 | return DONE; |
| 945 | } |
| 946 | |
| 947 | /* okay... time to deliver the content */ |
| 948 | if ((err = (*resource->hooks->deliver)(resource, |
| 949 | r->output_filters)) != NULL) { |
| 950 | err = dav_push_error(r->pool, err->status, 0, |
| 951 | "Unable to deliver content.", |
| 952 | err); |
| 953 | return dav_handle_err(r, err, NULL); |
| 954 | } |
| 955 | |
| 956 | return DONE; |
| 957 | } |
| 958 | |
| 959 | /* validate resource/locks on POST, then pass to the default handler */ |
| 960 | static int dav_method_post(request_rec *r) |
no test coverage detected