If Header
Topic Last Modified: 2006-06-13
The WebDAV If header describes a series of state lists.
If = "If" ":" (1*No-tag-list | 1*Tagged-list)
No-tag-list = List
Tagged-list = Resource 1*List
Resource = Coded-URL
List = "(" 1*(["Not"] (State-token | "["entity-tag "]")) ")"
State-token = Coded-URL
Coded-URL = "<" absoluteURI ">"
The No-tag-list production describes a series of state tokens and ETags. If multiple No-tag-list productions are used, then only one needs to match the state of the resource for the method to continue. If a method is applied to multiple resources, then the No-tag-list must be applied to each resource that the method is applied to.
The Tagged-list production creates a scope for a list production. The scope of the resource production begins with the list production immediately following the resource production, and ends with the next resource production, if there is one. When the If header is applied to a particular resource, the Tagged-list production must be searched to determine if any of the listed resources match the operand resources for the current method.
The If header may be used with a transaction lock token, with or without a Transaction Header also being submitted. The method will fail if the transaction is not valid. Using the If header with a transaction lock token will not include the method in the scope of the transaction.
Examples
The following is an example of a No-tag-list If header, where any resources within the scope of the method must be locked with the specified lock token and in the state identified by the "I am an ETag" ETag:
If: (<locktoken:a-write-lock-token> ["I am an ETag"])
The following is an example of a Tagged-list If header. When the method is first applied to https://www.contoso.com/resource1, resource1 must be in the state specified by (<locktoken:a-write-lock-token> [W/"A weak ETag"]) (["strong ETag"]). It must be locked with a lock token of locktoken:a-write-lock-token and have a weak entity tag, W/"A weak ETag", or it must have a strong entity tag, "strong ETag".
COPY /resource1 HTTP/1.1
Host: www.contoso.com
Destination: https://www.contoso.com/resource2
If: <https://www.contoso.com/resource1> (<locktoken:a-write-lock-token>
[W/"A weak ETag"]) (["strong ETag"])
<http://www.fabrikam.com/random> (["another strong ETag"[)