+
+ /* determine base version from etag in if-match header */
+ /*
+ Note: The -matchesRequestConditionInContext: already checks whether the
+ etag matches and returns an HTTP exception in case it doesn't.
+ We retrieve the etag again here to _ensure_ a transactionally save
+ commit.
+ (between the check and the update a change could have been done)
+ */
+ etag = [rq headerForKey:@"if-match"];
+ etag = [self parseETagList:etag];
+ if ([etag count] > 0) {
+ if ([etag count] > 1) {
+ /*
+ Note: we would have to attempt a save for _each_ of the etags being
+ passed in! In practice most WebDAV clients submit exactly one
+ etag.
+ */
+ [self warnWithFormat:
+ @"Got multiple if-match etags from client, only attempting to "
+ @"save with the first: %@", etag];
+ }
+
+ etag = [etag objectAtIndex:0];
+ }
+ baseVersion = ([etag length] > 0)
+ ? [etag unsignedIntValue]
+ : 0 /* 0 means 'do not check' */;
+
+ /* attempt a save */
+
+ if ((error = [self saveContentString:[rq contentAsString]
+ baseVersion:baseVersion]) != nil)