MCPcopy Create free account
hub / github.com/apache/httpd / dav_validate_resource_state

Function dav_validate_resource_state

modules/dav/main/util.c:899–1476  ·  view source on GitHub ↗

dav_validate_resource_state: * Returns NULL if path/uri meets if-header and lock requirements */

Source from the content-addressed store, hash-verified

897 * Returns NULL if path/uri meets if-header and lock requirements
898 */
899static dav_error * dav_validate_resource_state(apr_pool_t *p,
900 const dav_resource *resource,
901 dav_lockdb *lockdb,
902 const dav_if_header *if_header,
903 int flags,
904 dav_buffer *pbuf,
905 request_rec *r)
906{
907 dav_error *err;
908 const char *uri;
909 const char *etag;
910 const dav_hooks_locks *locks_hooks = (lockdb ? lockdb->hooks : NULL);
911 const dav_if_header *ifhdr_scan;
912 dav_if_state_list *state_list;
913 dav_lock *lock_list;
914 dav_lock *lock;
915 int num_matched;
916 int num_that_apply;
917 int seen_locktoken;
918 apr_size_t uri_len;
919 const char *reason = NULL;
920
921 /* DBG1("validate: <%s>", resource->uri); */
922
923 /*
924 ** The resource will have one of three states:
925 **
926 ** 1) No locks. We have no special requirements that the user supply
927 ** specific locktokens. One of the state lists must match, and
928 ** we're done.
929 **
930 ** 2) One exclusive lock. The locktoken must appear *anywhere* in the
931 ** If: header. Of course, asserting the token in a "Not" term will
932 ** quickly fail that state list :-). If the locktoken appears in
933 ** one of the state lists *and* one state list matches, then we're
934 ** done.
935 **
936 ** 3) One or more shared locks. One of the locktokens must appear
937 ** *anywhere* in the If: header. If one of the locktokens appears,
938 ** and we match one state list, then we are done.
939 **
940 ** The <seen_locktoken> variable determines whether we have seen one
941 ** of this resource's locktokens in the If: header.
942 */
943
944 /*
945 ** If this is a new lock request, <flags> will contain the requested
946 ** lock scope. Three rules apply:
947 **
948 ** 1) Do not require a (shared) locktoken to be seen (when we are
949 ** applying another shared lock)
950 ** 2) If the scope is exclusive and we see any locks, fail.
951 ** 3) If the scope is shared and we see an exclusive lock, fail.
952 */
953
954 if (lockdb == NULL) {
955 /* we're in State 1. no locks. */
956 lock_list = NULL;

Callers 2

dav_validate_walkerFunction · 0.85
dav_validate_requestFunction · 0.85

Calls 5

dav_lock_queryFunction · 0.85
dav_push_errorFunction · 0.85
dav_new_errorFunction · 0.85
dav_set_bufsizeFunction · 0.85

Tested by

no test coverage detected