<?xml version="1.0" encoding="US-ASCII"?>
<?xml-stylesheet type="text/xsl" href="rfc2629.xslt"?>
<?rfc rfcedstyle="yes" ?>
<?rfc toc="yes"?>
<?rfc tocdepth="4"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes"?>
<?rfc compact="yes"?>
<?rfc subcompact="no"?>

<rfc category="std" number="5689" updates="4791, 4918" ipr="pre5378Trust200902">
  <front>
    <title abbrev="Extended MKCOL for WebDAV">Extended MKCOL for Web Distributed Authoring and Versioning
(WebDAV)</title>
    <author initials="C." surname="Daboo" fullname="Cyrus Daboo">
      <organization abbrev="Apple Inc.">
        Apple Inc. 
      </organization>
      <address>
        <postal>
          <street>
            1 Infinite Loop 
          </street>
          <city>
            Cupertino 
          </city>
          <region>
            CA 
          </region>
          <code> 95014 </code> 
          <country>
            USA 
          </country>
        </postal>
        <email>
          cyrus@daboo.name 
        </email>
        <uri>
          http://www.apple.com/ 
        </uri>
      </address>
    </author>
    <date month="September" year="2009"></date>
    <area>
      Applications 
    </area>

    <keyword>webdav</keyword>
    <keyword>HTTP</keyword>

    <abstract>
      <t>
        This specification extends the Web Distributed Authoring and
        Versioning (WebDAV) MKCOL (Make Collection) method to allow collections of arbitrary resourcetype to be created and to allow properties to be set at the same time. 
      </t>
    </abstract>

  </front>
  <middle>
    <section title='Introduction'>
      <t>
        WebDAV <xref target="RFC4918"/> defines the HTTP
        <xref target="RFC2616" /> method MKCOL. This method is used to
        create WebDAV collections on the server. However, several
        WebDAV-based specifications (e.g., CalDAV
        <xref target="RFC4791"/>) define "special" collections -- ones
        that are identified by additional values in the
        DAV:resourcetype property assigned to the collection resource
        or by other means. These "special" collections are created by new methods (e.g., MKCALENDAR). The addition of a new MKxxx method for each new "special" collection adds to server complexity and is detrimental to overall reliability due to the need to make sure intermediaries are aware of these methods.
      </t>
      <t>
        This specification defines an extension to the WebDAV MKCOL
        method that adds a request body allowing a client to specify
        WebDAV properties to be set on the newly created collection or
        resource. In particular, the DAV:resourcetype property can be
        used to create a "special" collection; alternatively, other properties
        can be used to create a "special" resource. This avoids the need to invent new MKxxx methods.
      </t>
    </section>
    <section title='Conventions Used in This Document'>
      <t>
        The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in <xref target='RFC2119' />. 
      </t>
	  <t>
	  	This document uses XML DTD fragments (Section 3.2 of
	  	<xref target="W3C.REC-xml-20081126"/>) as a purely
	  	notational convention.  WebDAV request and response
	  	bodies cannot be validated by a DTD due to the
	  	specific extensibility rules defined in Section 17 of [RFC4918] and due to the fact that all XML elements defined by this specification use the XML namespace name "DAV:".  In particular:
		<list style='numbers'>
			<t>Element names use the "DAV:" namespace.</t>
			<t>Element ordering is irrelevant unless explicitly stated.</t>
			<t>Extension elements (elements not already defined as valid child elements) may be added anywhere, except when explicitly stated otherwise.</t>
			<t>Extension attributes (attributes not already defined as valid for this element) may be added anywhere, except when explicitly stated otherwise.</t>
		</list>
	  </t>
	  <t>
	    When an XML element type in the "DAV:" namespace is referenced in this document outside of the context of an XML fragment, the string "DAV:" will be prefixed to the element type.
	  </t>
	  <t>
        This document inherits, and sometimes extends, DTD productions
        from Section 14 of <xref target="RFC4918"/>.
      </t>
    </section>
    <section title='WebDAV Extended MKCOL'>
      <t>
        The WebDAV MKCOL request is extended to allow the inclusion of a request body. The request body is an XML document containing a single DAV:mkcol XML element as the root element. The Content-Type request header MUST be set appropriately for an XML body (e.g., set to "text/xml" or "application/xml"). XML-typed bodies for an MKCOL request that do not have DAV:mkcol as the root element are reserved for future usage.
      </t>
      <t>
        One or more DAV:set XML elements may be included in the
        DAV:mkcol XML element to allow setting properties on the
        collection as it is created. In particular, to create a
        collection of a particular type, the DAV:resourcetype XML
        element MUST be included in a DAV:set XML element and MUST
        specify the expected resource type elements for the new
        resource, which MUST include the DAV:collection element that
        needs to be present for any WebDAV collection.
      </t>
      <t>
        As per the PROPPATCH method (Section 9.2 of
        <xref target="RFC4918"/>), servers MUST process any DAV:set
        instructions in document order (an exception to the normal
        rule that ordering is irrelevant). If any one instruction
        fails to execute successfully, all instructions MUST fail
        (i.e., either all succeed or all fail).  Thus, if any error
        occurs during processing, all executed instructions MUST be
        undone and a proper error result returned. Failure to set a
        property value on the collection MUST result in a failure of
        the overall MKCOL request -- i.e., the collection is not created.
      </t>
      <t>
        The response to an extended MKCOL request MUST be an XML document containing a single DAV:mkcol-response XML element, which MUST contain DAV:propstat XML elements with the status of each property when the request fails due to a failure to set one or more of the properties specified in the request body. The server MAY return a response body in the case where the request is successful, indicating success for setting each property specified in the request body. When an empty response body is returned with a success request status code, the client can assume that all properties were set.
      </t>
      <t>
        In all other respects, the behavior of the extended MKCOL request follows that of the standard MKCOL request.
      </t>

	  <section title="Extended MKCOL Support" anchor="capability">
		<t>
			A server supporting the features described in
			this document MUST include "extended-mkcol" as
			a field in the DAV response header from an
			OPTIONS request on any URI that supports use
			of the extended MKCOL method.
		</t>
		<section title="Example: Using OPTIONS for the Discovery of Support for Extended MKCOL">
			<figure>
				<preamble>&gt;&gt; Request &lt;&lt;</preamble>
				<artwork type="message/http; msgtype=&#34;request&#34;"><![CDATA[
OPTIONS /addressbooks/users/ HTTP/1.1
Host: addressbook.example.com
]]></artwork>
			</figure>
			<figure>
				<preamble>&gt;&gt; Response &lt;&lt;</preamble>
				<artwork type="message/http; msgtype=&#34;response&#34;"><![CDATA[
HTTP/1.1 200 OK
Allow: OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, COPY, MOVE
Allow: MKCOL, PROPFIND, PROPPATCH, LOCK, UNLOCK, REPORT, ACL
DAV: 1, 2, 3, access-control, extended-mkcol
Date: Sat, 11 Nov 2006 09:32:12 GMT
Content-Length: 0
]]></artwork>
			</figure>
		</section>
</section>
      <section title="Status Codes">
        <t>
          As per Section 9.3.1 of <xref target="RFC4918"/>.
        </t>
      </section><!-- Status Codes -->

      <section title="Additional Precondition for Extended MKCOL">
        <t>
          WebDAV (<xref target="RFC4918"/>, Section 16) defines preconditions and postconditions for request behavior. This specification adds the following precondition for the extended MKCOL request.
        </t>
        <t>
            <list style="hanging">
                <t hangText="Name:">
                    valid-resourcetype
                </t>
                <t hangText="Namespace:">
                    DAV:
                </t>
                <t hangText="Use with:">
                    Typically 403 (Forbidden)
                </t>
                <t hangText="Purpose:">
                    (precondition) -- The server MUST support the specified resourcetype value for the specified collection.
                </t>
			</list>
        </t>
      </section><!-- Status Codes -->

      <section title="Example: Successful Extended MKCOL Request">

        <t>
          This example shows how the extended MKCOL request is used to create a collection of a fictitious type "special-resource". The response body is empty as the request completed successfully.
        </t>

        <figure>
          <preamble>&gt;&gt; Request &lt;&lt;</preamble>
          <artwork type="message/http; msgtype=&#34;request&#34;"><![CDATA[
MKCOL /home/special/ HTTP/1.1
Host: special.example.com
Content-Type: application/xml; charset="utf-8"
Content-Length: xxxx

<?xml version="1.0" encoding="utf-8" ?>
<D:mkcol xmlns:D="DAV:"
              xmlns:E="http://example.com/ns/">
  <D:set>
    <D:prop>
      <D:resourcetype>
        <D:collection/>
        <E:special-resource/>
      </D:resourcetype>
      <D:displayname>Special Resource</D:displayname>
    </D:prop>
  </D:set>
</D:mkcol> 
          ]]></artwork>
        </figure>
        <figure>
          <preamble>&gt;&gt; Response &lt;&lt;</preamble>
          <artwork type="message/http; msgtype=&#34;response&#34;"><![CDATA[
HTTP/1.1 201 Created
Cache-Control: no-cache
Date: Sat, 11 Nov 2006 09:32:12 GMT
          ]]></artwork>
        </figure>
      </section>

      <section title="Example: Unsuccessful Extended MKCOL Request">

        <t>
          This example shows an attempt to use the extended MKCOL
          request to create a collection of a fictitious type
          "special-resource", which is not actually supported by the
          server. The response body shows that an error occurred
          specifically with the DAV:resourcetype property.
        </t>

        <figure>
          <preamble>&gt;&gt; Request &lt;&lt;</preamble>
          <artwork type="message/http; msgtype=&#34;request&#34;"><![CDATA[
MKCOL /home/special/ HTTP/1.1
Host: special.example.com
Content-Type: application/xml; charset="utf-8"
Content-Length: xxxx

<?xml version="1.0" encoding="utf-8" ?>
<D:mkcol xmlns:D="DAV:"
              xmlns:E="http://example.com/ns/">
  <D:set>
    <D:prop>
      <D:resourcetype>
        <D:collection/>
        <E:special-resource/>
      </D:resourcetype>
      <D:displayname>Special Resource</D:displayname>
    </D:prop>
  </D:set>
</D:mkcol> 
          ]]></artwork>
        </figure>
        <figure>
          <preamble>&gt;&gt; Response &lt;&lt;</preamble>
          <artwork type="message/http; msgtype=&#34;response&#34;"><![CDATA[
HTTP/1.1 403 Forbidden
Cache-Control: no-cache
Date: Sat, 11 Nov 2006 09:32:12 GMT
Content-Type: application/xml; charset="utf-8"
Content-Length: xxxx

<?xml version="1.0" encoding="utf-8" ?>
<D:mkcol-response xmlns:D="DAV:">
  <D:propstat>
    <D:prop>
      <D:resourcetype/>
    </D:prop>
    <D:status>HTTP/1.1 403 Forbidden</D:status>
    <D:error><D:valid-resourcetype /></D:error>
    <D:responsedescription>Resource type is not
    supported by this server</D:responsedescription>
  </D:propstat>
  <D:propstat>
    <D:prop>
      <D:displayname/>
    </D:prop>
    <D:status>HTTP/1.1 424 Failed Dependency</D:status>
  </D:propstat>
</D:mkcol-response> 
          ]]></artwork>
        </figure>
      </section>

    </section>
    <section title='Using Extended MKCOL as an Alternative for MKxxx Methods'>
      <t>One of the goals of this extension is to eliminate the need for other extensions to define their own variant of MKCOL to create the special collections they need. This extension can be used as an alternative to existing MKxxx methods in other extensions as detailed below. If a server supports this extension and the other extension listed, then the server MUST support use of the extended MKCOL method to achieve the same result as the MKxxx method of the other extension.</t>

      <section title="MKCALENDAR Alternative">
        <t>CalDAV defines the MKCALENDAR method to create a calendar
        collection as well as to set properties during creation
        (Section 5.3.1 of <xref target="RFC4791"/>).</t>

        <t>The extended MKCOL method can be used instead by specifying both DAV:collection and CALDAV:calendar-collection XML elements in the DAV:resourcetype property, set during the extended MKCOL request.</t>

      <section title="Example: Using MKCOL Instead of MKCALENDAR">
        <t>
          The first example below shows an MKCALENDAR request containing a CALDAV:mkcalendar XML element in the request body and returning a CALDAV:mkcalendar-response XML element in the response body.
        </t>
        <figure>
          <preamble>&gt;&gt; MKCALENDAR Request &lt;&lt;</preamble>
          <artwork type="message/http; msgtype=&#34;request&#34;"><![CDATA[
MKCALENDAR /home/lisa/calendars/events/ HTTP/1.1
Host: calendar.example.com
Content-Type: application/xml; charset="utf-8"
Content-Length: xxxx

<?xml version="1.0" encoding="utf-8" ?>
<C:mkcalendar xmlns:D="DAV:"
              xmlns:C="urn:ietf:params:xml:ns:caldav">
  <D:set>
    <D:prop>
      <D:displayname>Lisa's Events</D:displayname>
    </D:prop>
  </D:set>
</C:mkcalendar> 
          ]]></artwork>
        </figure>
        <figure>
          <preamble>&gt;&gt; MKCALENDAR Response &lt;&lt;</preamble>
          <artwork type="message/http; msgtype=&#34;response&#34;"><![CDATA[
HTTP/1.1 201 Created
Cache-Control: no-cache
Date: Sat, 11 Nov 2006 09:32:12 GMT
Content-Type: application/xml; charset="utf-8"
Content-Length: xxxx

<?xml version="1.0" encoding="utf-8" ?>
<C:mkcalendar-response xmlns:D="DAV:"
              xmlns:C="urn:ietf:params:xml:ns:caldav">
  <D:propstat>
    <D:prop>
      <D:displayname/>
    </D:prop>
    <D:status>HTTP/1.1 200 OK</D:status>
  </D:propstat>
</C:mkcalendar-response> 
          ]]></artwork>
        </figure>
        <t>
          The second example shows the equivalent extended MKCOL request with the same request and response XML elements.
        </t>
        <figure>
          <preamble>&gt;&gt; MKCOL Request &lt;&lt;</preamble>
          <artwork type="message/http; msgtype=&#34;request&#34;"><![CDATA[
MKCOL /home/lisa/calendars/events/ HTTP/1.1
Host: calendar.example.com
Content-Type: application/xml; charset="utf-8"
Content-Length: xxxx

<?xml version="1.0" encoding="utf-8" ?>
<D:mkcol xmlns:D="DAV:"
              xmlns:C="urn:ietf:params:xml:ns:caldav">
  <D:set>
    <D:prop>
      <D:resourcetype>
        <D:collection/>
        <C:calendar/>
      </D:resourcetype>
      <D:displayname>Lisa's Events</D:displayname>
    </D:prop>
  </D:set>
</D:mkcol> 
          ]]></artwork>
        </figure>
        <figure>
          <preamble>&gt;&gt; MKCOL Response &lt;&lt;</preamble>
          <artwork type="message/http; msgtype=&#34;response&#34;"><![CDATA[
HTTP/1.1 201 Created
Cache-Control: no-cache
Date: Sat, 11 Nov 2006 09:32:12 GMT
Content-Type: application/xml; charset="utf-8"
Content-Length: xxxx

<?xml version="1.0" encoding="utf-8" ?>
<D:mkcol-response xmlns:D="DAV:"
              xmlns:C="urn:ietf:params:xml:ns:caldav">
  <D:propstat>
    <D:prop>
      <D:resourcetype/>
      <D:displayname/>
    </D:prop>
    <D:status>HTTP/1.1 200 OK</D:status>
  </D:propstat>
</D:mkcol-response> 
          ]]></artwork>
        </figure>
      </section>
      </section>
    </section>
    <section title='XML Element Definitions'>
      <section title='mkcol XML Element'>
        <t>
            <list style="hanging">
                <t hangText="Name:">
                    mkcol
                </t>
                <t hangText="Namespace:">
                    DAV:
                </t>
                <t hangText="Purpose:">
                    Used in a request to specify properties to be set in an extended MKCOL request, as well as any additional information needed when creating the resource.
                </t>
                <t hangText="Description:">
                    This XML element is a container for the information required to modify the properties on a collection resource as it is created in an extended MKCOL request.
                </t>
                <t hangText="Definition:">
                    <figure>
                        <artwork type="application/xml-dtd"><![CDATA[
    <!ELEMENT mkcol (set+)>
                        ]]></artwork>
                    </figure>
                </t>
            </list>
        </t>
      </section>
      <section title='mkcol-response XML Element'>
        <t>
            <list style="hanging">
                <t hangText="Name:">
                    mkcol-response
                </t>
                <t hangText="Namespace:">
                    DAV:
                </t>
                <t hangText="Purpose:">
                    Used in a response to indicate the status of properties that were set or failed to be set during an extended MKCOL request.
                </t>
                <t hangText="Description:">
                    This XML element is a container for the information returned about a resource that has been created in an extended MKCOL request.
                </t>
                <t hangText="Definition:">
                    <figure>
                        <artwork type="application/xml-dtd"><![CDATA[
    <!ELEMENT mkcol-response (propstat+)>
                        ]]></artwork>
                    </figure>
                </t>
            </list>
        </t>
      </section>
    </section>
    <section title='Security Considerations'>
      <t>
        This extension does not introduce any new security concerns
beyond those already described in HTTP <xref target="RFC2616" /> and
WebDAV <xref target="RFC4918" />. 
      </t>
    </section>

    <section title='Acknowledgments'>
      <t>
        Thanks to Bernard Desruisseaux, Mike Douglass, Alexey Melnikov, Julian Reschke, and Simon Vaillancourt.
      </t>
    </section>
  </middle>
  <back>
<?rfc rfcedstyle="no" ?>
    <references title='Normative References'>
<reference anchor='RFC2119'>

<front>
<title abbrev='RFC Key Words'>Key words for use in RFCs to Indicate Requirement Levels</title>
<author initials='S.' surname='Bradner' fullname='Scott Bradner'>
<organization>Harvard University</organization>
<address>
<postal>
<street>1350 Mass. Ave.</street>
<street>Cambridge</street>
<street>MA 02138</street></postal>
<phone>- +1 617 495 3864</phone>
<email>sob@harvard.edu</email></address></author>
<date year='1997' month='March' />
</front>
<seriesInfo name='BCP' value='14' />
<seriesInfo name='RFC' value='2119' />
</reference>
<reference anchor='RFC2616'>

<front>
<title abbrev='HTTP/1.1'>Hypertext Transfer Protocol -- HTTP/1.1</title>
<author initials='R.' surname='Fielding' fullname='Roy T. Fielding'>
<organization abbrev='UC Irvine'>Department of Information and Computer Science</organization>
<address>
<postal>
<street>University of California, Irvine</street>
<city>Irvine</city>
<region>CA</region>
<code>92697-3425</code></postal>
<facsimile>+1(949)824-1715</facsimile>
<email>fielding@ics.uci.edu</email></address></author>
<author initials='J.' surname='Gettys' fullname='James Gettys'>
<organization abbrev='Compaq/W3C'>World Wide Web Consortium</organization>
<address>
<postal>
<street>MIT Laboratory for Computer Science, NE43-356</street>
<street>545 Technology Square</street>
<city>Cambridge</city>
<region>MA</region>
<code>02139</code></postal>
<facsimile>+1(617)258-8682</facsimile>
<email>jg@w3.org</email></address></author>
<author initials='J.' surname='Mogul' fullname='Jeffrey C. Mogul'>
<organization abbrev='Compaq'>Compaq Computer Corporation</organization>
<address>
<postal>
<street>Western Research Laboratory</street>
<street>250 University Avenue</street>
<city>Palo Alto</city>
<region>CA</region>
<code>94305</code></postal>
<email>mogul@wrl.dec.com</email></address></author>
<author initials='H.' surname='Frystyk' fullname='Henrik Frystyk Nielsen'>
<organization abbrev='MIT/LCS'>World Wide Web Consortium</organization>
<address>
<postal>
<street>MIT Laboratory for Computer Science, NE43-356</street>
<street>545 Technology Square</street>
<city>Cambridge</city>
<region>MA</region>
<code>02139</code></postal>
<facsimile>+1(617)258-8682</facsimile>
<email>frystyk@w3.org</email></address></author>
<author initials='L.' surname='Masinter' fullname='Larry Masinter'>
<organization abbrev='Xerox'>Xerox Corporation</organization>
<address>
<postal>
<street>MIT Laboratory for Computer Science, NE43-356</street>
<street>3333 Coyote Hill Road</street>
<city>Palo Alto</city>
<region>CA</region>
<code>94034</code></postal>
<email>masinter@parc.xerox.com</email></address></author>
<author initials='P.' surname='Leach' fullname='Paul J. Leach'>
<organization abbrev='Microsoft'>Microsoft Corporation</organization>
<address>
<postal>
<street>1 Microsoft Way</street>
<city>Redmond</city>
<region>WA</region>
<code>98052</code></postal>
<email>paulle@microsoft.com</email></address></author>
<author initials='T.' surname='Berners-Lee' fullname='Tim Berners-Lee'>
<organization abbrev='MIT/LCS'>World Wide Web Consortium</organization>
<address>
<postal>
<street>MIT Laboratory for Computer Science, NE43-356</street>
<street>545 Technology Square</street>
<city>Cambridge</city>
<region>MA</region>
<code>02139</code></postal>
<facsimile>+1(617)258-8682</facsimile>
<email>timbl@w3.org</email></address></author>
<date year='1999' month='June' />
</front>
<seriesInfo name='RFC' value='2616' />
</reference>
<reference anchor='RFC4791'>

<front>
<title abbrev='CalDAV'>Calendaring Extensions to WebDAV (CalDAV)</title>
<author initials='C.' surname='Daboo' fullname='Cyrus Daboo'>
<organization abbrev='Apple'>Apple Inc.</organization>
<address>
<postal>
<street>1 Infinite Loop</street>
<city>Cupertino</city>
<region>CA</region>
<code>95014</code>
<country>USA</country></postal>
<email>cyrus@daboo.name</email>
<uri>http://www.apple.com/</uri></address></author>
<author initials='B.' surname='Desruisseaux' fullname='Bernard Desruisseaux'>
<organization abbrev='Oracle'>Oracle Corporation</organization>
<address>
<postal>
<street>600 Blvd. de Maisonneuve West</street>
<street>Suite 1900</street>
<city>Montreal</city>
<region>QC</region>
<code>H3A 3J2</code>
<country>CANADA</country></postal>
<email>bernard.desruisseaux@oracle.com</email>
<uri>http://www.oracle.com/</uri></address></author>
<author initials='L.M.' surname='Dusseault' fullname='Lisa Dusseault'>
<organization abbrev='CommerceNet'>CommerceNet</organization>
<address>
<postal>
<street>169 University Ave.</street>
<city>Palo Alto</city>
<region>CA</region>
<code>94301</code>
<country>USA</country></postal>
<email>ldusseault@commerce.net</email>
<uri>http://commerce.net/</uri></address></author>
<date year='2007' month='March' />
</front>
<seriesInfo name='RFC' value='4791' />
</reference>
<reference anchor='RFC4918'>

<front>
<title>HTTP Extensions for Web Distributed Authoring and Versioning (WebDAV)</title>
<author initials='L.' surname='Dusseault' fullname='L. Dusseault'>
<organization /></author>
<date year='2007' month='June' />
</front>
<seriesInfo name='RFC' value='4918' />
</reference>
<reference anchor='W3C.REC-xml-20081126'
           target='http://www.w3.org/TR/2008/REC-xml-20081126'>
<front>
<title>Extensible Markup Language (XML) 1.0 (Fifth Edition)</title>
<author initials='E.' surname='Maler' fullname='Eve Maler'>
    <organization />
</author>
<author initials='F.' surname='Yergeau' fullname='Francois Yergeau'>
    <organization />
</author>
<author initials='J.' surname='Paoli' fullname='Jean Paoli'>
    <organization />
</author>
<author initials='T.' surname='Bray' fullname='Tim Bray'>
    <organization />
</author>
<author initials='C.' surname='Sperberg-McQueen' fullname='C. M. Sperberg-McQueen'>
    <organization />
</author>
<date month='November' day='26' year='2008' />
</front>
<seriesInfo name='World Wide Web Consortium Recommendation' value='REC-xml-20081126' />
</reference>
    </references>
<?rfc rfcedstyle="yes" ?>
  </back>
</rfc>