<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet type="text/xsl" href="../../rfc2629.xslt"?><!DOCTYPE rfc SYSTEM 'rfc2629.dtd'[<!ENTITY rfc2119 PUBLIC '' 'bibxml/reference.RFC.2119.xml'><!ENTITY rfc2616 PUBLIC '' 'bibxml/reference.RFC.2616.xml'><!ENTITY rfc4791 PUBLIC '' 'bibxml/reference.RFC.4791.xml'><!ENTITY rfc5234 PUBLIC '' 'bibxml/reference.RFC.5234.xml'><!ENTITY rfc5545 PUBLIC '' 'bibxml/reference.RFC.5545.xml'><!ENTITY rfc5546 PUBLIC '' 'bibxml/reference.RFC.5546.xml'><!ENTITY rfc6266 PUBLIC '' 'bibxml/reference.RFC.6266.xml'><!ENTITY idCalDAVSCheduling SYSTEM 'bibxml3/reference.I-D.desruisseaux-caldav-sched.xml'>]><?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?><?rfc toc="yes"?><?rfc comments="yes"?><?rfc inline="yes"?><?rfc symrefs="yes"?><?rfc sortrefs="yes"?><?rfc compact="yes"?><?rfc subcompact="no"?><?rfc tocdepth="2"?><?rfc strict="yes"?><rfc category="std" ipr='trust200902' docName='draft-daboo-caldav-attachments-00'>  <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>    <date />    <area>Applications</area>    <keyword>CalDAV</keyword>    <keyword>CardDAV</keyword>    <keyword>calendaring</keyword>    <keyword>contacts</keyword>    <keyword>iCalendar</keyword>    <keyword>vCard</keyword>    <abstract>      <t>This document defines how CalDAV servers can provide server managed collections to allow attachments associated with iCalendar data, to be stored and managed on the server.</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'>iTIP</xref> to handle scheduling operations between calendar users.</t>      <t><xref target="RFC4791" /> defines the CalDAV Calendar Access protocol, based on <xref target="RFC2616">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 provides a solution to this problem whereby the client sends 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 privileges . The server can also provide additional information to the client about each attachment, such as the size and an identifier, so clients can manage their list of attachments directly from the calendar data.</t>    </section>    <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 <xref target='RFC2119' />.</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="Open Issues (to be removed prior to publication as a RFC)">      <t>        <list style="numbers">          <t>Since clients need to reload the calendar object resource after a POST operation, should we provide a way for the client to request the server to return the calendar data in the successful POST response?</t>          <t>Do we need a way to allow for multiple attachments to be added, updated or removed in a single POST (batching)?</t>          <t>Do we really need POST to remove given that a client PUT is pretty easy to do? Only benefit for POST is the request has no body.</t>          <t>SIZE uses iCalendar integer - but that is limited to 2^31. However attachments could exceed that size.</t>          <t>Do we need a REPORT to allow clients to detect the largest attachments affecting a user's quota? Should there be a request to purge all attachments older than some cut-off?</t>          <t>Do we need a way for the server to indicate limits for managed attachments (individual size, total size, total number etc). Also a way for a server to indicate it does not allow inline attachments?</t>        </list>      </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 for which the attachment is required. One exception to this is the delete operation, which additionally allows for attachment removal by the client simply updating the calendar object resource and removing any "ATTACH" properties. The retrieve operation is accomplished by simply issuing an HTTP GET request targeting the attachment URI.</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 updating 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 query parameters on the POST request-URI.</t>      <section title="Discovering Support for Managed Attachments">        <t>Servers advertise support for this extension by including the token "calendar-managed-attachments" in the DAV response header to an OPTIONS request on a calendar home collection. Clients MUST check for the presence of that token before using any of the features defined by this specification.</t>      </section>      <section title="POST Request for Managing Attachments">      	<t>An HTTP POST request is used to add, update, or remove attachments. 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 behavior the client is requesting. This parameter MUST be present once on each POST request used to manage attachments. One of 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 on a calendar object resource. See <xref target="attachment-remove" /> for more details.</t>      	    </list>      	  </t>        <figure>          <preamble>            Example:          </preamble> <artwork>http://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 instance is being targeted by the client for the attachment operation. The 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 only be present once.</t>      	      <t hangText="Specific instance">A specific iCalendar instance is targeted by using its "RECURRENCE-ID" value as the query parameter value. If multiple items of this form are used, they MUST be unique values.</t>      	    </list>      	    If the "rid" query parameter is not present, all recurrence instances in the calendar object resource are targeted.      	  </t>        <figure>          <preamble>            Example:          </preamble> <artwork>http://calendar.example.com/events/1.ics?  action=attachment-add&amp;rid=M,20111022T160000Z</artwork>        </figure>      	</section>      	<section title="id= Query Parameter" anchor="id=">      	  <t>The "id" query parameter is used to identify which "ATTACH" property is being updated or removed. The value of this query parameter MUST match the "MANAGED-ID" property parameter value on the "ATTACH" property in the calendar object resource instance(s) targeted by the request.      	  </t>        <figure>          <preamble>            Example:          </preamble> <artwork>http://calendar.example.com/events/1.ics?  action=attachment-update&amp;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 HTTP header describing the media type of the attachment (as required by HTTP).</t>            <t>The client SHOULD include a <xref target="RFC6266">Content-Disposition HTTP header</xref> with a "type" of "attachment", and a "filename" parameter that indicates the name of the attachment.</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" property parameter whose value is a unique identifier (within the context of the server as a whole). The "ATTACH" property SHOULD contain an "FMTTYPE" property parameter whose value matches the Content-Type header value from the request. The "ATTACH" property SHOULD include a "SIZE" property parameter whose value represents the size in octets of the attachment. 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 the overridden component with the appropriate "RECURRENCE-ID" property included.</t>            <t>Upon successful creation of the attachment resource and modification of the targeted calendar object resource, the server MUST return a 200 HTTP status response and include a Location HTTP header containing the URI of the stored attachment. The client can use the Location header value to correlate the attachment with "ATTACH" properties added to the calendar object resource. It is expected that the client will immediately reload the calendar object resource to refresh any local cache.</t>          </list>          </t>        </list>        </t>      </section>      <section title="Updating Attachments" anchor="attachment-update">        <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>If all recurrence instances are having an attachment updated, 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 an "id" query parameter with the value matching that of the "MANAGED-ID" property parameter for the "ATTACH" property being updated (see <xref target="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 describing the media type of the attachment (as required by HTTP).</t>            <t>The client SHOULD include a <xref target="RFC6266">Content-Disposition header</xref> with a "type" of "attachment", and a "filename" parameter that indicates the name of the attachment.</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 "id" query parameter is valid for the calendar object resource and specific instances being targeted.</t>            <t>Stores the supplied attachment data into a resource and generates an appropriate URI for clients to access the resource. The URI for the updated attachment data MUST be different from the one for the attachment being updated. This allows clients to use the URI value as a "change token".</t>            <t>For each affected recurrence instance in the calendar object resource targeted by the request, the server updates the "ATTACH" property, whose value is the URI of the updated attachment. The "MANAGED-ID" property parameter value MUST remain the same as it was for the attachment being updated. The "ATTACH" property SHOULD contain an "FMTTYPE" property parameter whose value matches the Content-Type header 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 include a "SIZE" property parameter whose value represents the size in octets of the updated attachment. 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 the overridden component with the appropriate "RECURRENCE-ID" property included.</t>            <t>Upon successful update of the attachment resource and modification of the targeted calendar object resource, the server MUST return a 200 HTTP status response and include a Location header containing the URI of the updated attachment. It is expected that the client will immediately reload the calendar object resource to refresh any local cache.</t>          </list>          </t>        </list>        </t>      </section>      <section title="Removing Attachments via POST" anchor="attachment-remove">        <t>To remove an attachment on 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-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 an "id" query parameter with the value matching that of the "MANAGED-ID" property parameter for the "ATTACH" property being removed (see <xref target="id="/>).</t>            <t>The body of the request will be empty.</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 "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 the overridden component with the appropriate "RECURRENCE-ID" property included, and the matching "ATTACH" property removed.</t>            <t>Upon successful removal of the attachment resource and modification of the targeted calendar object resource, the server MUST return a 200 HTTP status response. It is expected that the client will immediately reload the calendar object resource to refresh any local cache.</t>          </list>          </t>        </list>        </t>      </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>      </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).</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.</t>      </section>      <section title="Retrieving Attachments" anchor="attachment-retrieve">        <t>Clients retrieve attachments by simply issuing an HTTP GET request using the value of the corresponding "ATTACH" property as the request-URI.</t>      </section>      <section title="Additional Considerations">        <section title="Error Handling">          <t>TODO: error codes for each request.</t>        </section>        <section title="Access Control" anchor="acls">          <t>TODO: talk about authentication for attachment URIs, access limited to attendees only, or token based, only organizer able to re-use "ATTACH" properties.</t>        </section>        <section title="Server Redirects">          <t>For POST requests that add or update attachment data, the server MAY issue an HTTP redirect to require the client to re-issue the POST request using a different request-URI. As a result, it is always best for clients to use the "100 Continue" behavior define in Section 8.2.3 of <xref target="RFC2616" />. That ensures that, if a redirect does occur, the client does not needless send the attachment data.</t>          <t>When servers do redirect clients to a different request-URI, they SHOULD ensure that the authentication/authorization for the redirected URI falls within the same domain as that of the original URI, so that the client can re-use credentials without having to prompt the user.</t>        </section>        <section title="Server Clean-up">          <t>TODO: describe reference counting of managed attachments - server can remove actual attachment data once there are no more references to the attachment URI. Also, servers can purge old attachment data - return a 404 or 410.</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="I-D.desruisseaux-caldav-sched" />.</t>        </section>        <section title="Attendees managing Attachments">          <t>TODO: how do we do this? Organizer adds a property to calendar data to say attendees can add attachments, but how does scheduling happen?</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" "=" integer; positive integers or -1]]></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, if the attachment size exceeds that, the value -1 MUST instead be used.                    </t>                    <t hangText="Example:">                        <figure><artwork><![CDATA[ATTACH;SIZE=1234:http://attachments.example.com/abcd.txt]]></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 MAY be specified on "ATTACH" properties. Its value is generated by the server and uniquely identifies a managed attachment.                    </t>                    <t hangText="Example:">                        <figure><artwork><![CDATA[ATTACH;MANAGED-ID=aUNhbGVuZGFy:http://attachments.example.c om/abcd.txt]]></artwork></figure>                    </t>                </list>            </t>      </section>    </section>    <section title='Security Considerations'>      <t>TODO:servers need to enforce quotas, attachments could contain malicious content (virus checking could be done)</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='Paramater 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 Parameter</ttcol>          <ttcol>Status</ttcol>          <ttcol>Reference</ttcol>          <c>SIZE</c>          <c>Current</c>          <c>RFCXXXX, <xref target="SIZE-parameter" /></c>          <c>MANAGED-ID</c>          <c>Current</c>          <c>RFCXXXX, <xref target="MANAGED-ID-parameter" /></c>        </texttable>      </section>    </section>    <section title='Acknowledgments'>      <t>This specification came about via discussions at the Calendaring and Scheduling Consortium.</t>    </section>  </middle>  <back>    <references title='Normative References'>&rfc2119; &rfc2616; &rfc4791; &rfc5234; &rfc5545;&rfc6266; &idCalDAVSCheduling;</references>    <references title='Informative References'>&rfc5546;</references>    <!--<section title="Change History (To be removed by RFC Editor before publication)">            <t>                Changes in -01:                <list style='numbers'>                    <t></t>                </list>            </t>        </section>-->  </back></rfc>
