<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>
<!DOCTYPE rfc SYSTEM 'rfc2629.dtd'
[
<!ENTITY rfc2119 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml'>
<!ENTITY rfc2518 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.2518.xml'>
<!ENTITY rfc3864 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.3864.xml'>
<!ENTITY rfc4331 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.4331.xml'>
<!ENTITY rfc4791 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.4791.xml'>
<!ENTITY rfc4918 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.4918.xml'>
<!ENTITY rfc5023 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.5023.xml'>
<!ENTITY rfc5234 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.5234.xml'>
<!ENTITY rfc5545 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.5545.xml'>
<!ENTITY rfc5546 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.5546.xml'>
<!ENTITY rfc6266 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.6266.xml'>
<!ENTITY rfc7230 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.7230.xml'>
<!ENTITY rfc7231 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.7231.xml'>
<!ENTITY rfc7240 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.7240.xml'>
<!ENTITY rfc7320 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.7320.xml'>
<!ENTITY rfc6638 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.6638.xml'>
<!ENTITY rfc7538 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.7538.xml'>
<!ENTITY rfc7942 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.7942.xml'>
<!ENTITY rfc8144 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.8144.xml'>
<!ENTITY rfc8174 PUBLIC '' 'http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8174.xml'>
]>

<?rfc toc="yes"?>
<?rfc comments="yes"?>
<?rfc inline="yes"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes"?>
<?rfc compact="yes"?>
<?rfc subcompact="no"?>
<?rfc tocdepth="3"?>
<?rfc strict="yes"?>
<rfc category="info" ipr='trust200902'
     docName='draft-ietf-calext-caldav-attachments-04'>
  <front>
    <title abbrev="CalDAV Managed Attachments">CalDAV Managed Attachments</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="A." surname="Quillaud" fullname="Arnaud Quillaud">
    <organization abbrev="Oracle">Oracle Corporation</organization>
    <address>
      <postal>
        <street>180, Avenue de l'Europe</street>
        <city>Saint Ismier cedex</city>
        <region></region>
        <code>38334</code>
        <country>France</country>
      </postal>
      <email>arnaud.quillaud@oracle.com</email>
      <uri>http://www.oracle.com/</uri> 
   </address>
    </author>

    <author role="editor" initials="K." surname="Murchison"
            fullname="Kenneth Murchison">
      <organization abbrev="FastMail">FastMail US LLC</organization>
      <address> 
        <postal>
          <street>1429 Walnut St, Suite 1201</street>
          <city>Philadephia</city>
          <region>PA</region>
          <code>19102</code>
          <country>USA</country>
        </postal>
        <email>murch@fastmailteam.com</email> 
        <uri>http://www.fastmail.com/</uri>
      </address> 
    </author> 

    <date />

    <area>Applications and Real-Time</area> 
    <workgroup>Calendering Extensions</workgroup>

    <keyword>CalDAV</keyword>
    <keyword>calendaring</keyword>
    <keyword>attachment</keyword>
    <keyword>ATTACH</keyword>

    <abstract>
      <t>This specification defines an extension to the calendar
      access protocol (CalDAV) to allow attachments associated with
      iCalendar data to be stored and managed on the server.</t>

      <t>This specification documents existing code deployed by
      multiple vendors.  It is published as an Informational
      specification rather than Standards Track due to its
      noncompliance with multiple best current practices of HTTP.</t>
    </abstract>
  </front>

  <middle>
    <section title='Introduction'>
      <t>The <xref target='RFC5545'>iCalendar</xref> data format is
      used to represent calendar data and is used with <xref
      target='RFC5546'>iCalendar Transport-independent Interoperability
      Protocol (iTIP)</xref> to handle scheduling operations 
      between calendar users.</t>

      <t><xref target="RFC4791" /> defines the Calendaring Extensions
      to WebDAV (CalDAV),
      based on <xref target="RFC7230">HTTP</xref>, for
      accessing calendar data stored on a server.</t>

      <t>Calendar users often want to include attachments with their
      calendar data events or tasks (for example a copy of a
      presentation, or the meeting agenda). iCalendar provides an
      "ATTACH" property whose value is either the inline Base64
      encoded attachment data, or a URL specifying the location of the
      attachment data.</t>
      
      <t>Use of inline attachment data is not ideal with CalDAV
      because the data would need to be uploaded to the server each
      time a change to the calendar data is done - even minor changes
      such as a change to the summary. Whilst a client could choose to
      use a URL value instead, the problem then becomes where and how
      the client discovers an appropriate URL to use and how it
      ensures that only those attendees listed in the event or task
      are able to access it.</t>
      
      <t>This specification solves this problem by having the client
      send the attachment to the server, separately from the iCalendar
      data, and the server takes care of adding appropriate "ATTACH"
      properties in the iCalendar data as well as managing access
      privileges. The server can also provide additional information
      to the client about each attachment in the iCalendar data, such
      as the size and an identifier.</t>

      <section title='Rationale for Informational Status'>
        <t>Although this extension to CalDAV has wide deployment, its
        design does not comply with some of the best current practices
        of HTTP, namely:

      	<list style="symbols">
          <t>All operations on attachments are modeled as HTTP POST
          operations, where the actual type of operation is specified
          using a query parameter, instead of using separate HTTP POST,
          PUT, and DELETE methods where appropriate.</t>

          <t>Specific query strings are hardwired into the protocol
          in violation of Section 2.4 of <xref target="RFC7320" />.</t>
        </list></t>

        <t>Additionally, this extension misuses the
        <xref target="RFC6266">Content-Disposition header field</xref>
        as a request header field to convey a filename for an
        attachment rather than using an existing request header field
        suitable for that purpose, such as "Slug"
        (see Section 9.7 of <xref target="RFC5023" />).</t>

        <t>Rather than creating interoperability problems with deployed
        code by updating the design of this extension to be compliant
        with best current practices and to allow this specification to
        be placed on the Standards Track, it was decided to simply
        document how existing implementations interoperate and to
        publish the document as Informational.</t>
        
      </section> <!-- Rationale -->

    </section> <!-- Intro -->

    <section title='Conventions Used in This Document'>
      <t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL
      NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED",
      "MAY", and "OPTIONAL" in this document are to be interpreted as
      described in <eref target="https://tools.ietf.org/html/bcp14">BCP 14</eref>
      <xref target='RFC2119' /> <xref target='RFC8174' /> 
      when, and only when, they appear in all capitals, as shown here.</t>

      <t>The notation used in this memo is the ABNF notation of <xref
      target='RFC5234' /> as used by <xref
      target='RFC5545'>iCalendar</xref>. Any syntax elements shown
      below that are not explicitly defined in this specification come
      from <xref target='RFC5545'>iCalendar</xref>.</t>
    </section>

    <section title="Overview">
      <t>There are four main operations a client needs to do with
      attachments for calendar data: add, update, remove, and
      retrieve. The first three operations are carried out by the
      client issuing an HTTP POST request on the calendar object
      resource to which the attachment is associated and specifying
      the appropriate "action" query parameter (see <xref
      target="attachment-post-request"/>).  In the case of the 
      remove operation, the client can alternatively directly update
      the calendar object resource and remove the relevant "ATTACH"
      properties (see <xref target="attachment-remove-put"/>). The
      retrieve operation is accomplished by simply 
      issuing an HTTP GET request targeting the attachment URI
      specified by the calendar resource's "ATTACH" property (see
      <xref target="attachment-retrieve"/>).</t>
      
      <t>iCalendar data stored in a CalDAV calendar object resource
      can contain multiple components when recurrences are involved.
      In such a situation, the client needs to be able to target a
      specific recurrence instance or multiple instances when adding
      or deleting attachments.  As a result, the POST request needs to
      provide a way for the client to specify which recurrence
      instances should be targeted for the attachment operation.  This
      is accomplished through use of additional query parameters on
      the POST request-URI.</t>

      <section title="Requirements" anchor='requirements'>
        <t>A server that supports the features described in this
        specification is REQUIRED to support the CalDAV
        "calendar-access" <xref target="RFC4791"/> features.</t>
          
        <t>In addition, such a server SHOULD support the
        "return=representation" <xref target='RFC7240'>Prefer header
        field</xref> preference on successful HTTP PUT and POST requests
        targeting existing calendar object resources, by returning the
        new representation of that calendar resource (including its
        new ETag header field value) in the response.</t>
      </section>

      <section title="Discovering Support for Managed Attachments">
        <t>A server supporting the features described in this
        specification MUST include "calendar-managed-attachments" as a
        token in the DAV response header field (as defined in Section
        10.1 of <xref target="RFC4918" />) from an OPTIONS request on a
        calendar home collection.</t>
        
        <t>A server might choose to not support storing managed
        attachments on a per-recurrence instance basis (i.e., they can
        only be added to all instances as a whole). If that is the
        case, the server MUST also include
        "calendar-managed-attachments-no-recurrence" as a token in the
        DAV response header field from an OPTIONS request on a calendar home
        collection. When that field is present, clients MUST NOT
        attempt any managed attachment operations that target specific
        recurrence instances.</t>
      </section>

      <section title="POST Request for Managing Attachments"
               anchor="attachment-post-request">
      	<t>An HTTP POST request is used to add, update, or remove
        attachments.
        These requests are subject to the preconditions listed in
        <xref target="errors" />.
        The request-URI will contain various query
        parameters to specify the behavior.</t>

      	<section title="action= Query Parameter" anchor="action">
      	  <t>The "action" query parameter is used to identify which
          attachment operation the client is requesting. This
          parameter MUST be present once on each POST request used to
          manage attachments. One of these three values MUST be used:

      	  <list style="hanging">
      	    <t hangText="attachment-add">Indicates an operation that
            is adding an attachment to a calendar object resource. See
            <xref target="attachment-add" /> for more details.</t>

      	    <t hangText="attachment-update">Indicates an operation
            that is updating an existing attachment on a calendar
            object resource. See <xref target="attachment-update" />
            for more details.</t>
            
      	    <t hangText="attachment-remove">Indicates an operation
            that is removing an attachment from a calendar object
            resource. See <xref target="attachment-remove" /> for more
            details.</t>
      	  </list>
      	  </t>

          <figure>
            <preamble>
              Example:
            </preamble>
            <artwork>https://calendar.example.com/events/1.ics?action=attachment-add</artwork>
          </figure>      	  
      	</section>

      	<section title="rid= Query Parameter" anchor="rid">
      	  <t>The "rid" query parameter is used to identify which
          recurrence instances are being targeted by the client for
          the attachment operation. This query parameter MUST contain
          one or more items, separated by commas (0x2C). The item
          values can be in one of two forms:

      	  <list style="hanging">
      	    <t hangText="Master instance">The value "M"
            (case-insensitive) refers to the "master" recurrence
            instance, i.e., the component that does not include a
            "RECURRENCE-ID" property. This item MUST be present only
            once.</t>
            
      	    <t hangText="Specific instance">A specific iCalendar
            instance is targeted by using its "RECURRENCE-ID" value as
            the item value. That value MUST correspond to the
            RECURRENCE-ID value as stored in the calendar object
            resource (i.e. without any conversion to UTC). If multiple
            items of this form are used, they MUST be unique
            values.  For example, to target a recurrence defined by property
            RECURRENCE-ID;TZID=America/Montreal:20111022T160000, the
            query parameter rid=20111022T160000 would be used.</t>
      	  </list>
      	  If the "rid" query parameter is not present, all recurrence
          instances in the calendar object resource are targeted.
      	  </t>

          <t>The "rid" query parameter MUST NOT be present in the case
          of an update operation, or if the server chooses not to
          support per-recurrence instance managed attachments (see
          <xref target='requirements'/>).</t>

          <figure>
            <preamble>
              Example (targeting the master instance and a specific
              overridden instance):
            </preamble>
            <artwork>https://calendar.example.com/events/1.ics?
  action=attachment-add&amp;rid=M,20111022T160000</artwork>
          </figure>
      	</section>

      	<section title="managed-id= Query Parameter" anchor="managed-id">
      	  <t>The "managed-id" query parameter is used to identify
          which "ATTACH" property is being updated or removed. The
          value of this query parameter MUST match the <xref
          target="MANAGED-ID-parameter">"MANAGED-ID"</xref>
          property parameter value on the "ATTACH" property in the
          calendar object resource instance(s) targeted by the
          request.
      	  </t>

          <t>The "managed-id" query parameter MUST NOT be present in
          the case of an add operation.</t>
          <figure>
            <preamble>
              Example:
            </preamble>
            <artwork>https://calendar.example.com/events/1.ics?
  action=attachment-update&amp;managed-id=aUNhbGVuZGFy</artwork>
          </figure>
      	</section>
      </section>

      <section title="Adding attachments" anchor="attachment-add">
        <t>To add an attachment to an existing calendar object
        resource, the following occurs:

        <list style="numbers">
          <t>The client issues a POST request targeted at the calendar
          object resource.

          <list style="letters">
            <t>The request-URI will include an "action" query
            parameter with the value "attachment-add" (see <xref
            target="action"/>).</t>
            
            <t>If all recurrence instances are having an attachment
            added, the "rid" query parameter is not present in the
            request-URI. If one or more specific recurrence instances
            are targeted, then the request-URI will include a "rid"
            query parameter containing the list of instances (see
            <xref target="rid"/>).</t>
            
            <t>The body of the request contains the data for the
            attachment.</t>
            
            <t>The client MUST include a valid Content-Type
            header field describing the media type of the attachment (as
            required by HTTP).</t>
            
            <t>The client SHOULD include a <xref
            target="RFC6266">Content-Disposition header field</xref>
            with a "type" parameter set to "attachment", and a
            "filename" parameter that indicates the name of the
            attachment.  Note that the use of Content-Disposition as a
            request header field is nonstandard and specific to this
            protocol.</t>

            <t>The client MAY include a <xref target="RFC7240">Prefer
            header field</xref> with the "return=representation"
            preference to request that the modified calendar object
            resource be returned as the body of a successful response
            to the POST request.</t>
          </list>
          <vspace />
          </t>

          <t>When the server receives the POST request it does the following:
          <list style="letters">
            <t>Validates that any recurrence instances referred to via
            the "rid" query parameter are valid for the calendar
            object resource being targeted.</t>
            
            <t>Stores the supplied attachment data into a resource and
            generates an appropriate URI for clients to access the
            resource.</t>
            
            <t>For each affected recurrence instance in the calendar
            object resource targeted by the request, the server adds
            an "ATTACH" property, whose value is the URI of the stored
            attachment.
            The "ATTACH" property MUST contain a "MANAGED-ID"
            parameter whose value is a unique identifier (within the
            context of the server as a whole).
            The "ATTACH" property SHOULD contain an "FMTTYPE"
            parameter whose value matches the Content-Type header
            field value from the request.
            The "ATTACH" property SHOULD contain an "FILENAME"
            parameter whose value matches the Content-Disposition
            header field "filename" parameter value from the request, taking
            into account the restrictions expressed in <xref
            target="FILENAME-parameter"/>.
            The "ATTACH" property SHOULD include a "SIZE" parameter
            whose value represents the size in octets of the
            attachment.
            If a specified recurrence instance does not have a
            matching component in the calendar object resource, then
            the server MUST modify the calendar object resource to
            include an overridden component with the appropriate
            "RECURRENCE-ID" property.</t>

            <t>Upon successful creation of the attachment resource,
            and modification of the targeted calendar object resource,
            the server MUST return an appropriate HTTP success status
            response and include a "Cal-Managed-ID" header field
            containing the "MANAGED-ID" parameter value of the newly
            created "ATTACH" property. The client can use the
            "Cal-Managed-ID" header field value to correlate the attachment
            with "ATTACH" properties added to the calendar object
            resource.
            If the client included a Prefer header field with the
            "return=representation" preference in the request, the
            server SHOULD return the modified calendar object
            resource as the body of the response.  Otherwise, the
            server can expect that the client will reload the
            calendar object resource with a subsequent GET request to
            refresh any local cache.</t>
          </list>
          </t>
        </list>
      </t>

      <t>
        In the following example, the client adds a new attachment to
        a non recurring event and asks the server (via the <xref
        target='RFC7240'>Prefer</xref> header field) to return the
        modified version of that event in the response.
      </t>
      <figure>
        <preamble>
          &gt;&gt; Request &lt;&lt;
        </preamble>
        <artwork><![CDATA[
POST /events/64.ics?action=attachment-add HTTP/1.1
Host: cal.example.com
Content-Type: text/html; charset="utf-8"
Content-Disposition:attachment;filename=agenda.html
Content-Length: xxxx
Prefer: return=representation

<html>
  <body>
    <h1>Agenda</h1>
  </body>
</html>
]]></artwork>
      </figure>
      <figure>
        <preamble>
          &gt;&gt; Response &lt;&lt;
        </preamble>
        <artwork><![CDATA[
HTTP/1.1 201 Created
Content-Type: text/calendar; charset="utf-8"
Content-Length: yyyy
Content-Location: https://cal.example.com/events/64.ics
ETag: "123456789-000-111"
Cal-Managed-ID: 97S

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Example Corp.//CalDAV Server//EN
BEGIN:VEVENT
UID:20010712T182145Z-123401@example.com
DTSTAMP:20120201T203412Z
DTSTART:20120714T170000Z
DTEND:20120715T040000Z
SUMMARY:One-off meeting
ATTACH;MANAGED-ID=97S;FMTTYPE=text/html;SIZE=xxxx;
 FILENAME=agenda.html:https://cal.example.com/attach/64/34X22R
END:VEVENT
END:VCALENDAR
]]></artwork>
      </figure>
    </section>

    <section title="Updating Attachments" anchor="attachment-update">
      <t>When an attachment is updated the server MUST change the
      associated "MANAGED-ID" parameter and MAY change the "ATTACH"
      property value. With this approach, clients are able to
      determine when an attachment has been updated by some other
      client by looking for a change to either the "ATTACH" property
      value, or the "MANAGED-ID" parameter value.</t>
      
        <t>To change the data of an existing managed attachment in a
        calendar object resource, the following occurs:

        <list style="numbers">
          <t>The client issues a POST request targeted at the calendar
          object resource.

          <list style="letters">
            <t>The request-URI will include an "action" query
            parameter with the value "attachment-update" (see <xref
            target="action"/>).</t>
            
            <t>The request-URI will include a "managed-id" query
            parameter with the value matching that of the "MANAGED-ID"
            parameter for the "ATTACH" property being updated (see
            <xref target="managed-id"/>).</t>
            
            <t>The body of the request contains the updated data for
            the attachment.</t>
            
            <t>The client MUST include a valid Content-Type header field
            describing the media type of the attachment (as required
            by HTTP).</t>
            
            <t>The client SHOULD include a <xref
            target="RFC6266">Content-Disposition header field</xref> with a
            "type" parameter set to "attachment", and a "filename"
            parameter that indicates the name of the attachment.</t>

            <t>The client MAY include a <xref target="RFC7240">Prefer
            header field</xref> with the "return=representation"
            preference to request that the modified calendar object
            resource be returned as the body of a successful response
            to the POST request.</t>
          </list>
          <vspace />
          </t>

          <t>When the server receives the POST request it does the following:
          <list style="letters">
            <t>Validates that the "managed-id" query parameter is
            valid for the calendar object resource.</t>
            
            <t>Updates the content of the attachment resource
            corresponding to that managed-id with the supplied
            attachment data.</t>
            
            <t>For each affected recurrence instance in the calendar
            object resource targeted by the request, the server
            updates the "ATTACH" property whose "MANAGED-ID" property
            parameter value matches the "managed-id" query
            parameter. The "MANAGED-ID" parameter value is changed to
            allow other clients to detect the update, and the property
            value (attachment URI) might also be changed. The "ATTACH"
            property SHOULD contain a "FMTTYPE" parameter whose value
            matches the Content-Type header field value from the request -
            this could differ from the original value if the media
            type of the updated attachment is different. The "ATTACH"
            property SHOULD contain a "FILENAME" parameter whose value
            matches the Content-Disposition header field "filename"
            parameter value from the request, taking into account the
            restrictions expressed in <xref
            target="FILENAME-parameter"/>. The "ATTACH" property
            SHOULD include a "SIZE" parameter whose value represents
            the size in octets of the updated attachment.</t>
            
            <t>Upon successful update of the attachment resource, and
            modification of the targeted calendar object resource, the
            server MUST return an appropriate HTTP success status
            response, and include a "Cal-Managed-ID" header field
            containing the new value of the "MANAGED-ID" parameter.
            The client can use the
            "Cal-Managed-ID" header field value to correlate the attachment
            with "ATTACH" properties added to the calendar object
            resource.
            If the client included a Prefer header field with the
            "return=representation" preference in the request, the
            server SHOULD return the modified calendar object
            resource as the body of the response.  Otherwise, the
            server can expect that the client will reload the
            calendar object resource with a subsequent GET request to
            refresh any local cache.</t>
          </list>
          </t>
        </list>
        </t>

        <t>The update operation does not take a "rid" parameter and
        does not add, or remove, any "ATTACH" property in the
        targeted calendar object resource. To link an existing
        attachment to a new instance, the client simply does a PUT on
        the calendar object resource, adding an "ATTACH" property
        which duplicates the existing one (see <xref
        target="attachment-add-put"/>).</t>

        <t>
          In the following example, the client updates an existing
          attachment and asks the server (via the <xref
          target='RFC7240'>Prefer</xref> header field) to return the
          updated version of that event in the response.
        </t>
        <figure>
          <preamble>
            &gt;&gt; Request &lt;&lt;
          </preamble>
          <artwork><![CDATA[
POST /events/64.ics?action=attachment-update&managed-id=97S HTTP/1.1
Host: cal.example.com
Content-Type: text/html; charset="utf-8"
Content-Disposition:attachment;filename=agenda.html
Content-Length: xxxx
Prefer: return=representation

<html>
  <body>
    <h1>Agenda</h1>
    <p>Discuss attachment draft</p>
  </body>
</html>
]]></artwork>
        </figure>
        <figure>
          <preamble>
            &gt;&gt; Response &lt;&lt;
          </preamble>
          <artwork><![CDATA[
HTTP/1.1 200 OK
Content-Type: text/calendar; charset="utf-8"
Content-Length: yyyz
Content-Location: https://cal.example.com/events/64.ics
Cal-Managed-ID: 98S
ETag: "123456789-000-222"

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Example Corp.//CalDAV Server//EN
BEGIN:VEVENT
UID:20010712T182145Z-123401@example.com
DTSTAMP:20120201T203412Z
DTSTART:20120714T170000Z
DTEND:20120715T040000Z
SUMMARY:One-off meeting
ATTACH;MANAGED-ID=98S;FMTTYPE=text/html;SIZE=xxxy;
 FILENAME=agenda.html:https://cal.example.com/attach/64/34X22R
END:VEVENT
END:VCALENDAR
]]></artwork>
        </figure>
      </section>

      <section title="Removing Attachments via POST" anchor="attachment-remove">
        <t>To remove an existing attachment from a calendar object,
        the following occurs:

        <list style="numbers">
          <t>The client issues a POST request targeted at the calendar
          object resource.
          
          <list style="letters">
            <t>The request-URI will include an "action" query
            parameter with the value "attachment-remove" (see <xref
            target="action"/>).</t>
            
            <t>If all recurrence instances are having an attachment
            removed, the "rid" query parameter is not present in the
            request-URI. If one or more specific recurrence instances
            are targeted, then the request-URI will include a "rid"
            query parameter containing the list of instances (see
            <xref target="rid"/>).</t>
            
            <t>The request-URI will include a "managed-id" query
            parameter with the value matching that of the "MANAGED-ID"
            property parameter for the "ATTACH" property being removed
            (see <xref target="managed-id"/>).</t>
            
            <t>The body of the request will be empty.</t>

            <t>The client MAY include a <xref target="RFC7240">Prefer
            header field</xref> with the "return=representation"
            preference to request that the modified calendar object
            resource be returned as the body of a successful response
            to the POST request.</t>
          </list>
          <vspace />
          </t>

          <t>When the server receives the POST request it does the following:
          <list style="letters">
            <t>Validates that any recurrence instances referred to via
            the "rid" query parameter are valid for the calendar
            object resource being targeted.</t>
            
            <t>Validates that the "managed-id" query parameter is
            valid for the calendar object resource and specific
            instances being targeted.</t>

            <t>For each affected recurrence instance in the calendar
            object resource targeted by the request, the server
            removes the matching "ATTACH" property. Note that if a
            specified recurrence instance does not have a matching
            component in the calendar object resource, then the server
            MUST modify the calendar object resource to include an
            overridden component with the appropriate "RECURRENCE-ID"
            property, and the matching "ATTACH" property
            removed. This later case is actually valid only if the
            master component does include the referenced "ATTACH"
            property.</t>
            
            <t>If the attachment resource is no longer referenced by
            any instance of the calendar object resource, the server
            can delete the attachment resource to free up storage
            space.</t>
            
            <t>Upon successful removal of the attachment resource and
            modification of the targeted calendar object resource, the
            server MUST return an appropriate HTTP success status
            response.
            If the client included a Prefer header field with the
            "return=representation" preference in the request, the
            server SHOULD return the modified calendar object
            resource as the body of the response.  Otherwise, the
            server can expect that the client will reload the
            calendar object resource with a subsequent GET request to
            refresh any local cache.</t>
          </list>
          </t>
        </list>
        </t>

        <t>
          In the following example, the client deletes an existing
          attachment by passing its managed-id in the request.
          The <xref target='RFC7240'>Prefer</xref> header field is not
          set in the request so the calendar object resource data is
          not returned in the response.
        </t>
        <figure>
          <preamble>
            &gt;&gt; Request &lt;&lt;
          </preamble>
          <artwork><![CDATA[
POST /events/64.ics?action=attachment-remove&managed-id=98S HTTP/1.1
Host: cal.example.com
Content-Length: 0

]]></artwork>
        </figure>
        <figure>
          <preamble>
            &gt;&gt; Response &lt;&lt;
          </preamble>
          <artwork>
            <![CDATA[
HTTP/1.1 204 No Content
Content-Length: 0

]]></artwork>
        </figure>
      </section>

      <section title="Adding Existing Managed Attachments via PUT"
               anchor="attachment-add-put">
        <t>Clients can make use of existing managed attachments by
        adding the corresponding "ATTACH" property to calendar object
        resources (subject to the restrictions described in <xref
        target="acls"/>)</t>

        <t>If a managed attachment is used in more than calendar resource,
        servers SHOULD NOT change
        either the "MANAGED-ID" parameter value or the "ATTACH"
        property value for these attachments - this ensures that
        clients do not have to download the attachment data again if
        they already have it cached.
        Additionally, servers SHOULD validate
        "SIZE" parameter values and replace incorrect values with the
        actual sizes of existing attachments.</t>

        <t>These PUT requests are subject to the preconditions listed in
        <xref target="errors" />.</t>
      </section>

      <section title="Updating Attachments via PUT"
               anchor="attachment-update-put"> 
        <t>Servers MUST NOT allow clients to update attachment data
        directly via a PUT on the attachment URI (or via any other
        HTTP method that modifies content). Instead, attachments can
        only be updated via use of POST requests on the calendar
        data.</t>
      </section>

      <section title="Removing Attachments via PUT"
               anchor="attachment-remove-put">
        <t>Clients can remove attachments by simply re-writing the
        calendar object resource data to remove the appropriate
        "ATTACH" properties. Servers MUST NOT allow clients to delete
        attachments directly via a DELETE request on the attachment
        URI.</t>
      </section>

      <section title="Retrieving Attachments"
               anchor="attachment-retrieve">
        <t>Clients retrieve attachments by issuing an HTTP GET request
        using the value of the corresponding "ATTACH" property as the
        request-URI, taking into account the substitution mechanism
        associated with the "CALDAV:managed-attachments-server-URL"
        property (see <xref target="attach-server-URL-property" />).
        </t>
      </section>

      <section title="Error Handling" anchor="errors">
        <t>This specification creates additional preconditions for
        the POST method.</t>

        <t>The new preconditions are:
        <list>
          <t>(CALDAV:max-attachment-size): The attachment submitted
          in the POST request MUST have an octet size less than or
          equal to the value of the CALDAV:max-attachment-size
          property value (<xref
          target="max-attachment-size-property"/>) on the calendar
          collection of the target calendar resource;</t>
            
          <t>(CALDAV:max-attachments-per-resource): The addition of
          the attachment submitted in the POST request MUST result
          in the target calendar resource having a number of managed
          attachments less than or equal to the value of the
          CALDAV:max-attachments-per-resource property value (<xref
          target="max-attachments-per-resource-property"/>) on the
          calendar collection of the target calendar resource;</t>

          <t>(CALDAV:valid-action): The action query
          parameter in the POST request
          MUST contain one of "attachment-add", "attachment-update",
          or "attachment-remove".</t>

          <t>(CALDAV:valid-rid): The rid query
          parameter in the POST request
          MUST NOT be present for an attachment-update action, and
          MUST contain the value "M" and/or values corresponding to
          "RECURRENCE-ID" property values in the iCalendar
          data targeted by the request.</t>
            
          <t>(CALDAV:valid-managed-id): The managed-id query
          parameter in the POST request
          MUST NOT be present for an attachment-add action, and
          MUST contain a value corresponding to a
          "MANAGED-ID" property parameter value in the iCalendar
          data targeted by the request.</t>
        </list>
        </t>

        <t>A POST request to add, modify, or delete a managed
        attachment results in an implicit modification of the
        targeted calendar resource (equivalent of a PUT). As a
        consequence, clients should also be prepared to handle
        preconditions associated with this implicit PUT. This
        includes (but is not limited to):

        <list>
          <t>(CALDAV:max-resource-size) (from Section 5.3.2.1 of
          <xref target='RFC4791'/>)</t>
            
          <t>(DAV:quota-not-exceeded) (from Section 6 of <xref
          target='RFC4331'/>)</t>
            
          <t>(DAV:sufficient-disk-space) (from Section 6 of <xref
          target='RFC4331'/>)</t>
        </list>
        </t>

        <t>A PUT request to add or modify and existing calendar
        object resource can make reference to an existing managed
        attachment. The following new preconditions is defined:
        
        <list>
          <t>(CALDAV:valid-managed-id-parameter): a "MANAGED-ID"
          property parameter value in the iCalendar data in the PUT
          request is not valid (e.g., does not match any existing
          managed attachment).</t>
        </list>
        </t>

        <t>If a precondition for a request is not satisfied:

        <list style="numbers">
          <t>The response status of the request MUST either be
          403 (Forbidden), if the request should not be repeated because
          it will always fail, or 409 (Conflict), if it is expected that
          the user might be able to resolve the conflict and resubmit
          the request.</t>

          <t>The appropriate XML element MUST be returned as the
          child of a top-level DAV:error element in the response
          body.</t>
        </list></t>
      </section>

      <section title="Additional Considerations">
        <section title="Quotas" anchor="quotas">
          <t>The <xref target='RFC4331'>WebDAV Quotas</xref>
          specification defines two live WebDAV properties
          (DAV:quota-available-bytes and DAV:quota-used-bytes) to
          communicate storage quota information to clients.
          Server implementations MAY choose to include managed
          attachments sizes when calculating the amount of storage
          used by a particular resource.</t>
        </section>

        <section title="Access Control" anchor="acls">
        <t>Access to the managed attachments store in a calendar
        object resource SHOULD be restricted to only those calendar
        users who have access to that calendar object either directly,
        or indirectly (via being an attendee who would receive a
        scheduling message).</t>
        
        <t>When accessing a managed attachment, clients SHOULD be
        prepared to authenticate with the server storing the
        attachment resource. The credentials required to access the
        managed attachment store could be different from the ones used
        to access the CalDAV server.</t>
        
        <t>This specification only allows organizers of scheduled
        events to add managed attachments. Servers MUST prevent
        attendees of scheduled events from adding, updating or
        removing managed attachments. In addition, the server MUST
        prevent a calendar user from re-using a managed attachment
        (based on its managed-id value), unless that user is the one
        who originally created the managed attachment.</t>
        </section>

        <section title="Redirects" anchor="redirects">
          <t>For POST requests that add or update attachment data, the
          server MAY issue
          a <xref target="RFC7231">307 (Temporary Redirect)</xref>
          or <xref target="RFC7538">308 (Permanent Redirect)</xref>
          response to require the client to
          re-issue the POST request using a different request-URI. As
          a result, clients SHOULD use the
          "100-continue" expectation defined in Section 5.1.1 of
          <xref target="RFC7231" />.
          Using this mechanism ensures that, if a redirect does occur,
          the client does not needlessly send the attachment data.</t>
        </section>

        <section title="Processing Time" anchor="processing">
          <t>Clients can expect servers to take a while to respond to
          POST requests that include large attachment bodies. Servers
          SHOULD use the "102 (Processing)" interim response defined
          in Section 10.1 of <xref target="RFC2518" /> to keep the client
          connection alive if the POST request will take significant
          time to complete.</t>
        </section>

        <section title="Automatic Clean-Up by Servers" anchor="auto-cleanup">
          <t>Servers MAY automatically remove attachment data, for
          example to regain the storage taken by unused attachments,
          or as the result of a virus scanning. When doing so they
          SHOULD NOT modify calendar data referencing those
          attachments. Instead they SHOULD respond with "410 (Gone)"
          to any request on the removed attachment URI.</t>
        </section>

        <section title="Sending Scheduling Messages with Attachments">
          <t>When a managed attachment is added, updated or removed
          from a calendar object resource, the server MUST ensure that
          a scheduling message is sent to update any attendees with
          the changes, as per <xref target="RFC6638" />.</t>
        </section>

        <section title="Migrating Calendar Data">          
          <t>When exporting calendar data from a CalDAV server
          supporting managed attachments, clients SHOULD remove all
          "MANAGED-ID" property parameters from "ATTACH" properties in
          the calendar data. Similarly when importing calendar data
          from another source, clients SHOULD remove any "MANAGED-ID"
          property parameters on "ATTACH" properties (failure to do so
          will likely result in the server removing those properties
          automatically).</t>
        </section>
      </section>
    </section>

    <section title="Modifications to iCalendar Syntax">
      <section title="SIZE Property Parameter" anchor="SIZE-parameter">
        <t>
          <list style="hanging">
            <t hangText="Parameter Name:">SIZE</t>
            <t hangText="Purpose:">
              To specify the size of an attachment.
            </t>
            <t hangText="Format Definition:">
              This property parameter is defined by the following notation: 
              <figure><artwork name="abnf-rfc5234"><![CDATA[
sizeparam = "SIZE" "=" paramtext
; positive integers
]]></artwork></figure></t>
              <t hangText="Description:">
                This property parameter MAY be specified on "ATTACH"
                properties. It indicates the size in octets of the
                corresponding attachment data. Since iCalendar integer
                values are restricted to a maximum value of
                2147483647, the current parameter is defined as text
                to allow an extended range to be used.
              </t>
              <t hangText="Example:">
                <figure><artwork><![CDATA[
ATTACH;SIZE=1234:https://attachments.example.com/abcd.txt
]]></artwork></figure>
              </t>
          </list>
        </t>
      </section>

      <section title="FILENAME Property Parameter"
               anchor="FILENAME-parameter">
        <t>
          <list style="hanging">
            <t hangText="Parameter Name:">FILENAME</t>
            <t hangText="Purpose:">
              To specify the file name of a managed attachment.
            </t>
            <t hangText="Format Definition:">
              This property parameter is defined by the following notation: 
              <figure><artwork name="abnf-rfc5234"><![CDATA[
filenameparam = "FILENAME" "=" paramtext
]]></artwork></figure></t>
              <t hangText="Description:">
                This property parameter MAY be specified on "ATTACH"
                properties corresponding to managed attachments.
                Its value provides information on how to construct a
                filename for storing the attachment data.
                This parameter is very similar in nature to the
                Content-Disposition HTTP header field "filename" parameter
                and exposes the same security risks.
                As a consequence, clients MUST follow the guidelines
                expressed in Section 4.3 of <xref target="RFC6266" />
                when consuming this parameter value.
                Similarly, servers MUST follow those same guidelines
                before storing a value. 
              </t>
              <t hangText="Example:">
                <figure><artwork><![CDATA[
ATTACH;FILENAME=agenda.html:https://attachments.example.c
 om/rt452S
]]></artwork></figure>
              </t>
          </list>
        </t>
      </section>

      <section title="MANAGED-ID Property Parameter"
               anchor="MANAGED-ID-parameter">
        <t>
          <list style="hanging">
            <t hangText="Parameter Name:">MANAGED-ID</t>
            <t hangText="Purpose:">
              To uniquely identify a managed attachment.
            </t>
            <t hangText="Format Definition:">
              This property parameter is defined by the following notation: 
              <figure><artwork name="abnf-rfc5234"><![CDATA[
managedidparam = "MANAGED-ID" "=" paramtext
]]></artwork></figure></t>
              <t hangText="Description:">
                This property parameter MUST be specified on "ATTACH"
                properties corresponding to managed attachments.
                Its value is generated by the server and uniquely
                identifies a managed attachment within the scope of
                the CalDAV server.
                This property parameter MUST NOT be present in the
                case of non-managed attachments.
              </t>
              <t hangText="Example:">
                <figure><artwork><![CDATA[
ATTACH;MANAGED-ID=aUNhbGVuZGFy:https://attachments.example.c
 om/abcd.txt
]]></artwork></figure>
              </t>
          </list>
        </t>
      </section>
    </section>

    <section title="Additional Message Header Fields">
      <section anchor="managed-id-header"
               title="Cal-Managed-ID Response Header Field">
        <t>The Cal-Managed-ID response header field provides the value of
        the MANAGED-ID parameter corresponding to a newly added ATTACH
        property.</t>
        <figure>
          <preamble>ABNF:</preamble>
          <artwork name="abnf-rfc5545"><![CDATA[
Cal-Managed-ID = "Cal-Managed-ID" ":" paramtext
; "paramtext" is defined in Section 3.1 of [RFC5545]
]]></artwork>
        </figure>
        <figure>
          <preamble>Example:</preamble>
          <artwork><![CDATA[
Cal-Managed-ID:aUNhbGVuZGFy
]]></artwork>
        </figure>

        <t>The Cal-Managed-ID header field MUST only be sent by an
        origin server in response to a successful POST request with an
        action set to attachment-add or attachment-update.  It MUST
        only appear once in a response and MUST NOT appear in trailers.</t>

        <t>The Cal-Managed-ID header field is end to end and MUST be
        forwarded by intermediaries.  Intermediaries MUST NOT insert,
        delete, or modify a Cal-Managed-ID header field.</t>
      </section>
    </section>

    <section title="Additional WebDAV Properties">
      <section anchor="attach-server-URL-property"
               title="CALDAV:managed-attachments-server-URL property">
        <t>
          <list style="hanging">
            <t hangText="Name:">managed-attachments-server-URL</t>
            <t hangText="Namespace:">urn:ietf:params:xml:ns:caldav</t>
            <t hangText="Purpose:">Specifies the server base URI to
            use when retrieving managed attachments.</t>
            <t hangText="Protected:">This property MUST be protected
            as only the server can update the value.</t>
            <t hangText="COPY/MOVE behavior:">
              This property is only defined on a calendar home
            collection which cannot be moved or copied.</t>
            <t hangText="allprop behavior:">
            SHOULD NOT be returned by a PROPFIND DAV:allprop request.</t>
            <t hangText="Description:">
            This property MAY be defined on a calendar home
            collection. If present, it contains zero or one DAV:href
            XML elements.</t>
            
            <t>When one DAV:href element is present, its value MUST be
            an absolute HTTP URI containing only the scheme
            (i.e. "https") and authority (i.e. host and port) parts
            . Whenever a managed attachment is to be retrieved via an
            HTTP GET, the client MUST construct the actual URL of the
            attachment by substituting the scheme and authority parts
            of the attachment URI (as stored in the iCalendar "ATTACH"
            property) with the present WebDAV property value.</t>
            
            <t>When no DAV:href element is present, the client MUST
            substitute the scheme and authority parts of the
            attachment URI with the scheme and authority part of the
            calendar home collection absolute URI.</t>
            
            <t>In the absence of this property, the client can
            consider the attachment URI as its actual URL.</t>

            <t hangText="Definition:">
              <figure><artwork><![CDATA[
<!ELEMENT managed-attachments-server-URL (DAV:href?)>
]]></artwork></figure>
            </t>

            <t hangText="Example:">
              <figure><artwork><![CDATA[
<C:managed-attachments-server-URL xmlns:D="DAV:"
    xmlns:C="urn:ietf:params:xml:ns:caldav">
  <D:href>https://attachstore.example.com</D:href>
</C:managed-attachments-server-URL>
]]></artwork></figure>
            </t>
          </list>
        </t>
      </section>

      <section anchor="max-attachment-size-property" title="CALDAV:max-attachment-size property">
        <t>
          <list style="hanging">
            <t hangText="Name:">max-attachment-size</t>
            <t hangText="Namespace:">urn:ietf:params:xml:ns:caldav</t>
            <t hangText="Purpose:">
              Provides a numeric value indicating the maximum
              attachment size, in octets, that the server is willing
              to accept when a managed attachment is stored on the
              server.
            </t>
            <t hangText="Protected:">
              MUST be protected as it indicates limits provided by the
              server.
            </t>
            <t hangText="COPY/MOVE behavior:">
              This property value MUST be preserved in COPY and MOVE
              operations.
            </t>
            <t hangText="allprop behavior:">
              SHOULD NOT be returned by a PROPFIND DAV:allprop
              request.
            </t>
            <t hangText="Description:">
              The CALDAV:max-attachment-size property is used to
              specify a numeric value that represents the maximum
              attachment size, in octets, that the server is willing
              to accept when a managed attachment is stored on the
              server.
              The property is defined on the parent collection of the
              calendar object resource to which the attachment is
              associated.
              Any attempt to store a managed attachment exceeding this
              size MUST result in an error, with the
              CALDAV:max-attachment-size precondition (<xref
              target="errors" />) being violated.  In the absence of
              this property, the client can assume that the server
              will allow storing an attachment of any reasonable
              size.
            </t> 
            <t hangText="Definition:">
              <figure><artwork><![CDATA[
<!ELEMENT max-attachment-size (#PCDATA)>
<!-- PCDATA value: a numeric value (positive decimal integer) -->
]]></artwork></figure>
            </t>
            <t hangText="Example:">
              <figure><artwork><![CDATA[
<C:max-attachment-size xmlns:C="urn:ietf:params:xml:ns:caldav"
     >102400000</C:max-attachment-size>
]]></artwork></figure>
            </t>
          </list>
        </t>
      </section>

      <section anchor="max-attachments-per-resource-property" title="CALDAV:max-attachments-per-resource property">
        <t>
          <list style="hanging">
            <t hangText="Name:">max-attachments-per-resource</t>
            <t hangText="Namespace:">urn:ietf:params:xml:ns:caldav</t>
            <t hangText="Purpose:">
              Provides a numeric value indicating the maximum number
              of managed attachments across all instances of a
              calendar object resource stored in a calendar
              collection.
            </t>
            <t hangText="Protected:">
              MUST be protected as it indicates limits provided by the
              server.
            </t> 
            <t hangText="COPY/MOVE behavior:">
              This property value MUST be preserved in COPY and MOVE
              operations.
            </t> 
            <t hangText="allprop behavior:">
              SHOULD NOT be returned by a PROPFIND DAV:allprop
              request.
            </t>
            <t hangText="Description:">
              The CALDAV:max-attachments-per-resource property is used
              to specify a numeric value that represents the maximum
              number of managed attachments across all instances of a
              calendar object resource stored in a calendar
              collection.
              Non-managed attachments are not counted toward that limit.
              The property is defined on the parent collection of the
              calendar object resource to which the attachment is
              associated.
              Any attempt to add a managed attachment that would cause
              the calendar resource to exceed this limit MUST result
              in an error, with the
              CALDAV:max-attachments-per-resource precondition (<xref
              target="errors" />) being violated.
              In the absence of this property, the client can assume
              that the server can handle any number of managed
              attachments per calendar resource.
            </t>
            <t hangText="Definition:">
              <figure><artwork><![CDATA[
<!ELEMENT max-attachments-per-resource (#PCDATA)>
<!-- PCDATA value: a numeric value (positive decimal integer) -->
]]></artwork></figure>
            </t>
            <t hangText="Example:">
              <figure><artwork><![CDATA[
<C:max-attachments-per-resource
    xmlns:C="urn:ietf:params:xml:ns:caldav"
     >12</C:max-attachments-per-resource>
]]></artwork></figure>
            </t>
          </list>
        </t>
      </section>
    </section>

    <section title="Implementation Status" anchor="impl">

      <t>&lt; RFC Editor: before publication please remove this section,
	the reference to <xref target="RFC7942"/>, and any resulting
        "URIs" references sub-section. &gt;</t>

      <t>This section records the status of known implementations of
	the protocol defined by this specification at the time of
	posting of this Internet-Draft, and is based on a proposal
	described in <xref target="RFC7942"/>.  The
	description of implementations in this section is intended to
	assist the IETF in its decision processes in progressing
	drafts to RFCs.  Please note that the listing of any
	individual implementation here does not imply endorsement by
	the IETF.  Furthermore, no effort has been spent to verify the
	information presented here that was supplied by IETF
	contributors.  This is not intended as, and must not be
	construed to be, a catalog of available implementations or
	their features.  Readers are advised to note that other
	implementations may exist.</t>

	<t>According to <xref target="RFC7942"/>,
	"this will allow reviewers and working groups to assign due
	consideration to documents that have the benefit of running
	code, which may serve as evidence of valuable
	experimentation and feedback that have made the implemented
	protocols more mature.  It is up to the individual working
	groups to use this information as they see fit".</t>

      <section title="Calendar and Contacts Server"
	       anchor="calendarserver" toc="exclude"> 
	<t>The open
	  source <eref target="http://calendarserver.org/">Calendar
	  and Contacts Server</eref> project is a standards-compliant
	  server implementing the CalDAV protocol.  This
	  production level implementation supports all of the
	  requirements described in this document and successfully
	  interoperates with the <xref target="apple"
          format="title"/>, <xref target="busycal" format="title"/>,
          <xref target="twodo" format="title"/>, and <xref
          target="caldavtester" format="title"/> client
          implementations described below. This
	  implementation is freely distributable under the terms of
	  the <eref
	  target="http://www.apache.org/licenses/LICENSE-2.0.html">Apache
	License, Version 2.0</eref>.</t>
      </section>

      <section title="Cyrus Server" anchor="cyrus" toc="exclude">
	<t>The open source <eref
	target="http://www.cyrusimap.org/">Cyrus Server</eref> project is a 
	highly scalable enterprise mail system which also supports
	calendaring.  This production level CalDAV
	implementation supports all of the requirements described in
	this document and successfully interoperates with the  <xref
        target="apple" format="title"/> and <xref
	target="caldavtester" format="title"/> client 
	implementations described below.  This implementation is
	freely distributable under a BSD style license from
	<eref target="http://www.cmu.edu/computing/">Computing
	Services at Carnegie Mellon University</eref>.</t> 
      </section>

      <section title="Oracle Communications Calendar Server"
               anchor="oracle" toc="exclude">
	<t>The <eref
	target="http://www.cyrusimap.org/">Oracle Communications
        Calendar Server</eref> project is a standards-compliant,
	scalable, enterprise-ready calendaring solution.  This
        production level CalDAV 
	implementation supports all of the requirements described in
	this document and successfully interoperates with the <xref
        target="apple" format="title"/> and <xref
        target="caldavtester" format="title"/> client implementations
        described below. This implementation is proprietary and
        available for a free trial and/or purchase from the vendor.</t>
      </section>

      <section title="Apple Calendar" anchor="apple" toc="exclude"> 
	<t>The widely used <eref
        target="http://www.apple.com/macos/">Apple Calendar</eref>
        client is a standards-compliant client implementing the CalDAV
        protocol.  This production level implementation
        supports all the requirements described in this
        document and successfully interoperates with the <xref
        target="calendarserver" format="title"/>, <xref target="cyrus"
	format="title"/>, and <xref target="oracle" format="title"/>
        implementations described above. This 
	client implementation is proprietary and is distributed
        as part of Apple's desktop operating systems.</t>
      </section>

      <section title="BusyCal" anchor="busycal" toc="exclude">
	<t><eref target="http://www.busymac.com/busycal/">BusyCal</eref>
	is a standards-compliant calendar client for MacOS implementing
	the CalDAV protocol.  This implementation
        supports all of the requirements described in this document
	and successfully interoperates with the <xref target="calendarserver"
        format="title"/> and <xref target="cyrus"
	format="title"/> implementations described above. This
	implementation is proprietary and available for a free trial
        and/or purchase from the vendor.</t>
      </section>

      <section title="CalDAVTester" anchor="caldavtester" toc="exclude">
	<t><eref target="http://calendarserver.org/wiki/CalDAVTester">
	  CalDAVTester</eref> is an open source test and performance
	  application designed to work with CalDAV 
	  servers and tests various aspects of their protocol
	  handling as well as performance.  This widely used
	  implementation supports all of the requirements described in
	  this document and successfully interoperates with the server
	  implementations described above.  This implementation is
	  freely distributable under the terms of the <eref
	  target="http://www.apache.org/licenses/LICENSE-2.0.html">Apache
	  License, Version 2.0</eref>.</t>
      </section>

      <section title="2Do" anchor="twodo" toc="exclude">
	<t><eref target="http://www.2doapp.com/">2Do</eref>
	is a standards-complient calendar client for iOS which uses the
	CalDAV standard for communication.  This implementation
        supports all of the requirements described in this document
	and successfully interoperates with the <xref target="calendarserver"
        format="title"/> implementation described above. This
	implementation is proprietary and available for purchase from
        the vendor.</t>
      </section>
    </section> <!-- Implementations -->

    <section title='Security Considerations'>
      <t>The security considerations in <xref target="RFC4791" />
      and <xref target="RFC4918" /> apply to this extension.
      Additionally, servers need to be aware that a client could
      attack underlying storage by POSTing extremely large attachments
      and could attack processing time by uploading a recurring event
      with a large number of overrides and then repeatedly adding,
      updating, and deleting attachments.</t>

      <t>Malicious content could be introduced into the calendar
      server by way of a managed attachment, and propagated to many
      end users via scheduling. Servers SHOULD check managed
      attachments for malicious or inappropriate content. Upon
      detecting of such content, servers SHOULD remove the attachment,
      following the rules described in <xref
      target='auto-cleanup'/>.</t>
    </section>

    <section title='IANA Considerations'>
      <!--<section title='Property Registrations'>
        <t>This documents defines the following new iCalendar properties to be added to the registry defined in Section 8.2.3 of <xref target="RFC5545" />:</t>
        <texttable>
          <ttcol>Property</ttcol>
          <ttcol>Status</ttcol>
          <ttcol>Reference</ttcol>
        </texttable>
      </section>-->

      <section title='Parameter Registrations'>
        <t>This specification defines the following new iCalendar
        property parameters to be added to the registry defined in
        Section 8.2.3 of <xref target="RFC5545" />:</t>
        <texttable>
          <ttcol>Property Parameter</ttcol>
          <ttcol>Status</ttcol>
          <ttcol>Reference</ttcol>
          <c>SIZE</c>
          <c>Current</c>
          <c>RFCXXXX, <xref target="SIZE-parameter" /></c>
          <c>FILENAME</c>
          <c>Current</c>
          <c>RFCXXXX, <xref target="FILENAME-parameter" /></c>
          <c>MANAGED-ID</c>
          <c>Current</c>
          <c>RFCXXXX, <xref target="MANAGED-ID-parameter" /></c>
        </texttable>
      </section>

      <section title="Message Header Field Registrations">
        <t>
          The message header fields below should be added to the
          Permanent Message Header Field Registry (see  <xref
          target="RFC3864"/>).
        </t>
        <section title="Cal-Managed-ID">
          <t>Header field name: Cal-Managed-ID</t>
            <t>Applicable protocol: http</t>
            <t>Status: standard</t>
            <t>Author/Change controller: IETF</t>
            <t>Specification document(s): this specification (<xref
            target="managed-id-header"/>)
            </t>
            <t>Related information: none</t>
        </section>
      </section>
    </section>

    <section title='Acknowledgments'>
      <t>This specification came about via discussions at the
      Calendaring and Scheduling Consortium. Thanks in particular to
      Mike Douglass and Eric York.</t>
    </section>

  </middle>
  <back>

    <references title='Normative References'>
      &rfc2119;
      &rfc2518;
      &rfc3864;
      &rfc4331;
      &rfc4791;
      &rfc4918;
      &rfc5234;
      &rfc5545;
      &rfc6266;
      &rfc6638;
      &rfc7230;
      &rfc7231;
      &rfc7240;
      &rfc7538;
      &rfc8174;
    </references>

    <references title='Informative References'>
      &rfc5023;
      &rfc5546;
      &rfc7320;
      &rfc7942;
      &rfc8144;
    </references>

    <section title="Change History (To be removed by RFC Editor before
                    publication)">
      <t>
        Changes in calext-04:
        <list style='numbers'>
          <t>Added text explaining why this document is being
          published as Informational.</t>
          <t>Further specified Cal-Managed-ID per Section 8.3.1 of
          RFC 7231.</t>
          <t>Specified that the MANAGED-ID parameter value is unique
          within the scope of the server.</t>
          <t>Added more text regarding preconditions.</t>
          <t>Added text about specific DoS attack vectors.</t>
          <t>Editorial changes from Gren Elliot and Phillip Kewisch.</t>
          <t>Editorial changes from Adam Roach.</t>
          <t>Editorial changes from Alexey Melnikov.</t>
          <t>Added reference to RFC4918.</t>
          <t>Minor editorial changes.</t>
       </list>
      </t>
      <t>
        Changes in calext-03:
        <list style='numbers'>
          <t>Changed to Informational based on feedback regarding
          non-standard method of updating an existing resource.</t>
          <t>Added references to sub-sections in Overview.</t>
          <t>Made support for Prefer header field a SHOULD for servers.</t>
          <t>Expanded recurring event examples to use conditional
          requests and to include the Expect header field.</t>
          <t>Minor editorial changes.</t>
       </list>
      </t>
      <t>
        Changes in calext-02:
        <list style='numbers'>
          <t>Moved "Error Handling" into its own sub-section.</t>
          <t>Split "Other Client Considerations" into "Processing
          Time" and "Migrating Calendar Data".</t>
       </list>
      </t>
      <t>
        Changes in calext-01:
        <list style='numbers'>
          <t>Changed all instances of "header" to "header field".</t>
          <t>Reworked wording of Prefer header field handling.</t>
          <t>Switched to recommending 102 (Processing) interim
          response to keep the client connection alive.</t>
          <t>Fixed description of Cal-Managed-ID response header field
          to state that it is also required in responses to successful
          attachment-update.</t>
          <t>Minor editorial changes.</t> 
       </list>
      </t>
      <t>
        Changes in calext-00:
        <list style='numbers'>
          <t>Added Murchison as editor.</t>
          <t>Updated HTTP references to RFC7230 and RFC7231.</t>
          <t>Updated Prefer header field references to RFC7240.</t>
          <t>Added Implementation Status section.</t> 
          <t>Minor editorial changes.</t> 
       </list>
      </t>
      <t>
        Changes in daboo-03:
        <list style='numbers'>
          <t>Fixed some examples.</t>
          <t>Fixed return-representation -> return=representation.</t>
          <t>Added statement that servers must not allow clients to
          DELETE attachments directly.</t>
          <t>Added new preconditions for valid managed-id values.</t>
          <t>Filled out Access Control section.</t>
          <t>Allow servers to not support per-instance attachments and
          advertise that fact to clients.</t>
        </list>
      </t>
      <t>
        Changes in daboo-02:
        <list style='numbers'>
          <t>MANAGED-ID changes on PUT.</t>
          <t>MTAG has been removed.</t>
          <t>Error pre-conditions added.</t>
          <t>Interaction with WebDAV QUOTA discussed.</t>
          <t>max-attachment-* limits added.</t>
          <t>Updated references.</t>
          <t>Removed MUST for specific 2xx codes in favor of generic
          success code.</t>
        </list>
      </t>
      <t>
        Changes in daboo-01:
        <list style='numbers'>
          <t>Tweaked OPTIONS capability wording.</t>
          <t>Added section on clients expecting 100-Continue for
          delayed response.</t>
          <t>Added text for clean-up and use of HTTP 410 on orphans.</t>
          <t>Added text on removing "MANAGED-ID" when
          exporting/importing calendar data.</t>
          <t>Added protocol examples.</t>
          <t>Added MTAG property parameter on ATTACH property</t>
          <t>Added FILENAME property parameter on ATTACH property</t>
          <t>"id" query parameter is now "managed-id".</t>
          <t>Use of Cal-Managed-ID header instead of Location header
          in responses.</t>
          <t>rid query param MUST contain RECURRENCE-ID without any conversion to UTC (case
          of floating events).</t>
          <t>Introduced CALDAV:managed-attachments-server-URL property</t>
          <t>Made support for Prefer header a MUST for servers.</t>
        </list>
      </t>
    </section>

    <section title='Example Involving Recurring Events'>
      <t>
        In the following example, the organizer of a recurring meeting
        makes an unsuccessful attempt to add an agenda (HTML
        attachment) to the corresponding calendar resource with a
        conditional request.
        Note that the client includes both the Expect and Prefer
        header fields in the request, thereby preventing itself from
        needlessly sending the attachment data, and requesting that the
        current resource be returned in the failure response (see
        Section 3.2 of <xref target="RFC8144"/>).
      </t>
      <figure>
        <preamble>
          &gt;&gt; Request &lt;&lt;
        </preamble>
        <artwork><![CDATA[
POST /events/65.ics?action=attachment-add HTTP/1.1
Host: cal.example.com
Content-Type: text/html; charset="utf-8"
Content-Disposition: attachment;filename=agenda.html
Content-Length: xxxx
If-Match: "abcdefg-000"
Expect: 100-continue
Prefer: return=representation

]]></artwork>
      </figure>
      <figure>
        <preamble>
          &gt;&gt; Final Response &lt;&lt;
        </preamble>
        <artwork><![CDATA[
HTTP/1.1 412 Precondition Failed
Content-Type: text/calendar; charset="utf-8"
Content-Length: yyyy
Content-Location: https://cal.example.com/events/65.ics
ETag: "123456789-000-000"

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Example Corp.//CalDAV Server//EN
BEGIN:VTIMEZONE
LAST-MODIFIED:20040110T032845Z
TZID:America/Montreal
BEGIN:DAYLIGHT
DTSTART:20000404T020000
RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=4
TZNAME:EDT
TZOFFSETFROM:-0500
TZOFFSETTO:-0400
END:DAYLIGHT
BEGIN:STANDARD
DTSTART:20001026T020000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
TZNAME:EST
TZOFFSETFROM:-0400
TZOFFSETTO:-0500
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
UID:20010712T182145Z-123401@example.com
DTSTAMP:20120201T203412Z
DTSTART;TZID=America/Montreal:20120206T100000
DURATION:PT1H
RRULE:FREQ=WEEKLY
SUMMARY:Planning Meeting
ORGANIZER:mailto:cyrus@example.com
ATTENDEE;CUTYPE=INDIVIDUAL;PARTSTAT=ACCEPTED:mailto:cyrus@exampl
 e.com
ATTENDEE;CUTYPE=INDIVIDUAL;PARTSTAT=ACCEPTED:mailto:arnaudq@exam
 ple.com
ATTENDEE;CUTYPE=INDIVIDUAL;PARTSTAT=NEEDS-ACTION:mailto:mike@exa
 mple.com
END:VEVENT
END:VCALENDAR
]]></artwork>
      </figure>
      <t>
        The organizer of a recurring meeting successfully
        adds an agenda (HTML attachment) to the corresponding calendar
        resource.  Attendees of the meeting are granted read access to
        the newly created attachment resource. Their own copy of the
        meeting is updated to include the new ATTACH property pointing
        to the attachment resource and they are notified of the change
        via their scheduling inbox.
      </t>
      <figure>
        <preamble>
          &gt;&gt; Request &lt;&lt;
        </preamble>
        <artwork><![CDATA[
POST /events/65.ics?action=attachment-add HTTP/1.1
Host: cal.example.com
Content-Type: text/html; charset="utf-8"
Content-Disposition: attachment;filename=agenda.html
Content-Length: xxxx
If-Match: "123456789-000-000"
Expect: 100-continue
Prefer: return=representation

]]></artwork>
      </figure>
      <figure>
        <preamble>
          &gt;&gt; Interim Response &lt;&lt;
        </preamble>
        <artwork><![CDATA[
HTTP/1.1 100 Continue

]]></artwork>
      </figure>
      <figure>
        <preamble>
          &gt;&gt; Request Body &lt;&lt;
        </preamble>
        <artwork><![CDATA[
<html>
  <body>
    <h1>Agenda</h1>
    <p>As usual</p>
  </body>
</html>
]]></artwork>
      </figure>
      <figure>
        <preamble>
          &gt;&gt; Final Response &lt;&lt;
        </preamble>
        <artwork><![CDATA[
HTTP/1.1 201 Created
Content-Type: text/calendar; charset="utf-8"
Content-Length: yyyy
Content-Location: https://cal.example.com/events/65.ics
ETag: "123456789-000-111"
Cal-Managed-ID: 97S

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Example Corp.//CalDAV Server//EN
BEGIN:VTIMEZONE
LAST-MODIFIED:20040110T032845Z
TZID:America/Montreal
BEGIN:DAYLIGHT
DTSTART:20000404T020000
RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=4
TZNAME:EDT
TZOFFSETFROM:-0500
TZOFFSETTO:-0400
END:DAYLIGHT
BEGIN:STANDARD
DTSTART:20001026T020000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
TZNAME:EST
TZOFFSETFROM:-0400
TZOFFSETTO:-0500
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
UID:20010712T182145Z-123401@example.com
DTSTAMP:20120201T203412Z
DTSTART;TZID=America/Montreal:20120206T100000
DURATION:PT1H
RRULE:FREQ=WEEKLY
SUMMARY:Planning Meeting
ORGANIZER:mailto:cyrus@example.com
ATTENDEE;CUTYPE=INDIVIDUAL;PARTSTAT=ACCEPTED:mailto:cyrus@exampl
 e.com
ATTENDEE;CUTYPE=INDIVIDUAL;PARTSTAT=ACCEPTED:mailto:arnaudq@exam
 ple.com
ATTENDEE;CUTYPE=INDIVIDUAL;PARTSTAT=NEEDS-ACTION:mailto:mike@exa
 mple.com
ATTACH;MANAGED-ID=97S;FMTTYPE=text/html;SIZE=xxxx;
 FILENAME=agenda.html:https://cal.example.com/attach/65/34X22R
END:VEVENT
END:VCALENDAR
]]></artwork>
      </figure>
      <t>
        The organizer has a more specific agenda for the 20th of
        February meeting.
        It is added to that particular instance of the meeting by
        specifying the rid parameter.
        Note that an overridden instance is created with the
        RECURRENCE-ID property value matching the value of the "rid"
        query parameter in the request.
        Also note that the server takes significant time to complete the
        request and notifies the client accordingly.
      </t>
      <figure>
        <preamble>
          &gt;&gt; Request &lt;&lt;
        </preamble>
        <artwork><![CDATA[
POST /events/65.ics?action=attachment-add&rid=20120220T100000 HTTP/1.1
Host: cal.example.com
Content-Type: text/html; charset="utf-8"
Content-Disposition: attachment;filename=agenda0220.html
Content-Length: xxxx
If-Match: "123456789-000-111"
Expect: 100-continue
Prefer: return=representation

]]></artwork>
      </figure>
      <figure>
        <preamble>
          &gt;&gt; Interim Response &lt;&lt;
        </preamble>
        <artwork><![CDATA[
HTTP/1.1 100 Continue

]]></artwork>
      </figure>
      <figure>
        <preamble>
          &gt;&gt; Request Body &lt;&lt;
        </preamble>
        <artwork><![CDATA[
<html>
  <body>
    <h1>Agenda</h1>
    <p>Something different, for a change</p>
  </body>
</html>
]]></artwork>
      </figure>
      <figure>
        <preamble>
          &gt;&gt; Interim Response &lt;&lt;
        </preamble>
        <artwork><![CDATA[
HTTP/1.1 102 Processing

]]></artwork>
      </figure>
      <figure>
        <preamble>
          &gt;&gt; Final Response &lt;&lt;
        </preamble>
        <artwork><![CDATA[
HTTP/1.1 201 Created
Content-Type: text/calendar; charset="utf-8"
Content-Length: yyyy
Content-Location: https://cal.example.com/events/65.ics
ETag: "123456789-000-222"
Cal-Managed-ID: 33225

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Example Corp.//CalDAV Server//EN
BEGIN:VTIMEZONE
LAST-MODIFIED:20040110T032845Z
TZID:America/Montreal
BEGIN:DAYLIGHT
DTSTART:20000404T020000
RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=4
TZNAME:EDT
TZOFFSETFROM:-0500
TZOFFSETTO:-0400
END:DAYLIGHT
BEGIN:STANDARD
DTSTART:20001026T020000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
TZNAME:EST
TZOFFSETFROM:-0400
TZOFFSETTO:-0500
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
UID:20010712T182145Z-123401@example.com
DTSTAMP:20120201T203412Z
DTSTART;TZID=America/Montreal:20120206T100000
DURATION:PT1H
RRULE:FREQ=WEEKLY
SUMMARY:Planning Meeting
ORGANIZER:mailto:cyrus@example.com
ATTENDEE;CUTYPE=INDIVIDUAL;PARTSTAT=ACCEPTED:mailto:cyrus@exampl
 e.com
ATTENDEE;CUTYPE=INDIVIDUAL;PARTSTAT=ACCEPTED:mailto:arnaudq@exam
 ple.com
ATTENDEE;CUTYPE=INDIVIDUAL;PARTSTAT=NEEDS-ACTION:mailto:mike@exa
 mple.com
ATTACH;MANAGED-ID=97S;FMTTYPE=text/html;SIZE=xxxx;
 FILENAME=agenda.html:https://cal.example.com/attach/65/34X22R
END:VEVENT
BEGIN:VEVENT
UID:20010712T182145Z-123401@example.com
RECURRENCE-ID;TZID=America/Montreal:20120220T100000
DTSTAMP:20120201T203412Z
DTSTART;TZID=America/Montreal:20120220T100000
DURATION:PT1H
SUMMARY:Planning Meeting
ORGANIZER:mailto:cyrus@example.com
ATTENDEE;CUTYPE=INDIVIDUAL;PARTSTAT=ACCEPTED:mailto:cyrus@example.
 com
ATTENDEE;CUTYPE=INDIVIDUAL;PARTSTAT=ACCEPTED:mailto:arnaudq@exampl
 e.com
ATTENDEE;CUTYPE=INDIVIDUAL;PARTSTAT=NEEDS-ACTION:mailto:mike@examp
 le.com
ATTACH;MANAGED-ID=33225;FMTTYPE=text/html;SIZE=xxxx;
 FILENAME=agenda0220.html:https://cal.example.com/attach/65/FGZ225
END:VEVENT
END:VCALENDAR
]]></artwork>
      </figure>
    </section>
  </back>
</rfc>
