Individual Submission                                       L. Dusseault
Internet-Draft                                                      OSAF
Expires: April 14, 2005                                 October 14, 2004


            Partial Document Changes (PATCH Method) for HTTP
                     draft-dusseault-http-patch-06

Status of this Memo

   This document is an Internet-Draft and is subject to all provisions
   of section 3 of RFC 3667.  By submitting this Internet-Draft, each
   author represents that any applicable patent or other IPR claims of
   which he or she is aware have been or will be disclosed, and any of
   which he or she become aware will be disclosed, in accordance with
   RFC 3668.

   Internet-Drafts are working documents of the Internet Engineering
   Task Force (IETF), its areas, and its working groups.  Note that
   other groups may also distribute working documents as
   Internet-Drafts.

   Internet-Drafts are draft documents valid for a maximum of six months
   and may be updated, replaced, or obsoleted by other documents at any
   time.  It is inappropriate to use Internet-Drafts as reference
   material or to cite them other than as "work in progress."

   The list of current Internet-Drafts can be accessed at
   http://www.ietf.org/ietf/1id-abstracts.txt.

   The list of Internet-Draft Shadow Directories can be accessed at
   http://www.ietf.org/shadow.html.

   This Internet-Draft will expire on April 14, 2005.

Copyright Notice

   Copyright (C) The Internet Society (2004).

Abstract

   Several applications extending HTTP require a feature to do partial
   resource modification.  Existing HTTP functionality only allows a
   complete replacement of a document.  This proposal adds a new HTTP
   method, PATCH, to modify an existing HTTP resource.







Dusseault                Expires April 14, 2005                 [Page 1]


Internet-Draft                 HTTP PATCH                   October 2004


Table of Contents

   1.  Introduction . . . . . . . . . . . . . . . . . . . . . . . . .  3
   2.  Delta Encodings  . . . . . . . . . . . . . . . . . . . . . . .  5
   3.  Mechanisms . . . . . . . . . . . . . . . . . . . . . . . . . .  6
     3.1   PATCH Method . . . . . . . . . . . . . . . . . . . . . . .  6
     3.2   PATCH Response . . . . . . . . . . . . . . . . . . . . . .  7
       3.2.1   Success Response . . . . . . . . . . . . . . . . . . .  7
       3.2.2   Error handling . . . . . . . . . . . . . . . . . . . .  8
     3.3   Advertising Support in OPTIONS . . . . . . . . . . . . . .  9
   4.  Interdependencies with other Standards . . . . . . . . . . . . 11
     4.1   PATCH and Access Control (RFC3744) . . . . . . . . . . . . 11
   5.  IANA Considerations  . . . . . . . . . . . . . . . . . . . . . 12
   6.  Security Considerations  . . . . . . . . . . . . . . . . . . . 13
   7.  References . . . . . . . . . . . . . . . . . . . . . . . . . . 14
   7.1   Normative References . . . . . . . . . . . . . . . . . . . . 14
   7.2   Non-Normative References . . . . . . . . . . . . . . . . . . 14
       Author's Address . . . . . . . . . . . . . . . . . . . . . . . 14
   A.  Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . 15
   B.  Changes  . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
     B.1   Changes from -00 . . . . . . . . . . . . . . . . . . . . . 16
     B.2   Changes from -01 . . . . . . . . . . . . . . . . . . . . . 16
     B.3   Changes from -02 . . . . . . . . . . . . . . . . . . . . . 16
     B.4   Changes from -03 . . . . . . . . . . . . . . . . . . . . . 16
     B.5   Changes from -04 . . . . . . . . . . . . . . . . . . . . . 17
     B.6   Changes from -05 . . . . . . . . . . . . . . . . . . . . . 17
   C.  Notes to RFC Editor  . . . . . . . . . . . . . . . . . . . . . 18
       Intellectual Property and Copyright Statements . . . . . . . . 19























Dusseault                Expires April 14, 2005                 [Page 2]


Internet-Draft                 HTTP PATCH                   October 2004


1.  Introduction

   Three use cases initially motivated this proposal

   1.  WebDAV [3] is used by authoring applications to store and share
       files on the internet.  For example, Adobe Photoshop has a
       Workgroup feature allowing the user to browse a repository and
       save the file.  Currently, Photoshop only publishes the file to
       the repository rarely, because Photoshop files are typically
       large and upload is slow.  Worse, large uploads are more likely
       to be interrupted.  Although HTTP [1] provides byte range
       downloads, it does not provide a mechanism for partial uploads.
   2.  DeltaV [4] extends WebDAV to do versioning.  In versioning
       environments, a large number of files may be updated with very
       small changes.  For example, a programmer may change the name of
       a function used in a hundred source files.  Versioning
       applications typically send deltas or patches to the server to
       modify these files, however DetaV does not yet have this
       functionality.
   3.  The SIMPLE WG is devising a way to store and modify configuration
       information.  The biggest feature missing from HTTP is the
       ability to modify information in a very lightweight manner, so
       that the client that decides to change its presence state from
       "free" to "busy" doesn't have to upload a large document.  This
       can be accomplished through changes to a HTTP resource as well.

   Other working groups (like netconf) are also considering manipulating
   large files using HTTP GET and PUT.  Sometimes the files aren't that
   large but the device is small or bandwidth is limited, as when phones
   need to add a new contact to an address book file.  This feature
   would allow much more efficient changes to files.

   This specification defines a new HTTP 1.1 method to apply a delta
   encoding, or a "patch", to a HTTP resource.  A new method is
   necessary to improve interoperability and prevent errors.  The PUT
   method is already defined to overwrite a resource with a complete new
   body, and MUST NOT be reused to do partial changes.  Otherwise,
   proxies and caches and even clients and servers may get confused as
   to the result of the operation.

   Note that byte ranges are already used in HTTP to do partial
   downloads (GET method) as defined in RFC2616.  However, they are not
   defined for uploads, and there are some missing pieces for uploads.
   For example, the HTTP specification does not define a particularly
   informative error to send if the byte range in a PUT is invalid.
   Byte ranges (or some other kind of range) could be made to work in
   this specification but a more flexible mechanism (one that could also
   encompass XML delta encodings) was desired, as well as a method that



Dusseault                Expires April 14, 2005                 [Page 3]


Internet-Draft                 HTTP PATCH                   October 2004


   would not confuse caching proxies.  Reliable and tested delta
   encodings already exist, and this specification takes advantage of
   that existing work.

   Some delta encodings for use in HTTP GET responses are defined in RFC
   3229 [2].  That specification defines delta encodings for cache
   updates, not for user write operations.  It does mean that servers
   can reuse delta encoding algorithms to support both that
   specification and this proposal.

   This specification defines the new method PATCH to alter a single
   existing resource, in place, by applying a delta encoding.  A patch
   request body is modelled as a manipulation of an instance, where the
   instance would have been the entire document had it been PUT to the
   server, following the model of RFC3229 [2].  The operation is atomic.
   Note that WebDAV MOVE and COPY requests, if supported by the HTTP
   server, can be useful to independently rename or copy a whole
   resource before applying PATCH to either the source or destination
   URL to modify the contents.
































Dusseault                Expires April 14, 2005                 [Page 4]


Internet-Draft                 HTTP PATCH                   October 2004


2.  Delta Encodings

   A set of changes for a resource is itself a document, called a delta
   encoding.  The delta encoding is uniquely identified through a
   instance manipulation as defined in RFC3229.  Servers advertise
   supported delta encodings for PATCH by advertising these algorithms,
   and clients specify which one they're using by including the name in
   the request.  Not all instance-manipulations defined in the IANA
   registry are delta encodings; as of October 2004, the instance
   manipulations which are also delta encodings are vcdiff, diffe, and
   gdiff.

   Servers SHOULD support PATCH and the vcdiff delta encoding for all
   authorable resources, that is all resources that support PUT.  Some
   requirements apply only to specific patch formats, and in this
   specification those requirements are spelled out only for vcdiff.



































Dusseault                Expires April 14, 2005                 [Page 5]


Internet-Draft                 HTTP PATCH                   October 2004


3.  Mechanisms

3.1  PATCH Method

   The PATCH method requests that the request body (a delta encoding) be
   applied to the resource identified by the Request-URI.  The server
   MUST NOT create a new resource with the contents of the request body,
   although it MAY (depending on the delta encoding) apply the request
   body to an empty entity to result in the content for the new
   resource.

   The server MUST always apply the entire patch atomically and never
   provide (e.g.  in response to a GET during this operation) a
   partially-patched body.  If the entire patch file cannot be
   successfully applied then the server MUST fail the entire request,
   applying none of the changes.  See error handling section for details
   on status codes and possible error conditions.

   PATCH request bodies MUST NOT be cached.  A cache MAY mark the
   resource identified in the Request-URI as stale if it sees a
   successful response to the PATCH request.

   The PATCH request MUST have a body.  It MUST include the IM header
   with a single valid delta encoding.  The PATCH request MAY include a
   Content-Type header which is the content-type of the resource to
   which the delta encoding is to be applied.  The request body MUST be
   in the delta encoding format specified in the IM header.

   If the vcdiff format is used:

   o  The client MUST verify that it is applying the delta encoding to a
      known entity.  There are two reliable ways to do this.  The first
      way is to find out the resource ETag at the time the body is
      downloaded, and use that Etag in the If-Match header on the PATCH
      request to make sure the resource is still unchanged.  The second
      way to use WebDAV LOCK/UNLOCK to reserve the file (first LOCK,
      then GET, then PATCH, then UNLOCK).  Vcdiff collisions from
      multiple users are more dangerous than PUT collisions, because a
      vcdiff that is not operating from a known base point may corrupt
      the resource.  Therefore, if neither strong ETags nor LOCKS are
      available from the server, the client MUST use If-Unmodified-Since
      as a less-reliable safeguard.
   o  If the Request-URI does not identify an existing resource, the
      server SHOULD (subject of course to access control and other
      restrictions) create a resource with an empty body and apply the
      vcdiff changes to that empty entity.  A client SHOULD verify that
      the URL is unmapped, as expected, with use of the "If-None-Match:
      *" header.



Dusseault                Expires April 14, 2005                 [Page 6]


Internet-Draft                 HTTP PATCH                   October 2004


   o  The Content-Type header specifies the client's intended
      Content-Type for the resource being patched.  Thus, if the server
      creates a new resource it MUST assign this Content-Type, or assign
      a generic one if the Content-Type header was not provided.  If the
      server modifies an existing resource, the server MUST change the
      Content-Type if a new Content-Type was provided by the client;
      otherwise the resource's   Content-Type should remain unchanged.

   Simple PATCH example


       PATCH /file.txt HTTP/1.1
       Host: www.example.com
       Content-type: text/plain
       IM: vcdiff
       If-Match: "e0023aa4e"
       Content-Length: 100

       [vcdiff-bytes]


                                Figure 1

   This example illustrates use of the vcdiff algorithm on an existing
   text file.

3.2  PATCH Response

3.2.1  Success Response

   A successful response with the 204 No Content status code implies
   that no new resource was created.  A successful response with the 201
   Created status code informs the client that a new resource was
   created.

   The server SHOULD send the Content-MD5 header in responses to PATCH.
   This allows the client to verify the success of the operation.

   As with PUT, the PATCH method MUST change the resource's ETag if the
   resulting entity is not identical to the original.  If the server
   supports strong ETags, the server MUST return a strong ETag for use
   in future client operations.  The server MUST return the
   Last-Modified header if it does not support strong ETags.

   Successful PATCH response to existing text file

       HTTP/1.1 204 No Content
       Content-MD5: Q2hlY2sgSW50ZWdyaXR5IQ==



Dusseault                Expires April 14, 2005                 [Page 7]


Internet-Draft                 HTTP PATCH                   October 2004


       ETag: "e0023aa4e"



3.2.2  Error handling

   This proposal uses the same mechanism as DeltaV (defined in section
   1.6 of RFC3253) to add machine-parsable information to provide more
   detail than HTTP status codes can.  Existing HTTP status codes are
   not infinitely extensible but XML elements and namespaces are more
   so, and it's simple to treat the HTTP error code as a rough category
   and put detailed error codes in the body.  Clients that do not use
   the extra information ignore the bodies of error responses.  These
   error codes are not meant to be displayed directly to end-users, so
   there is no language code or other display information.  Clients MUST
   ignore any unrecognized elements within the XML response body because
   extensions allow implementors to add custom debug information to the
   response.

   The PATCH method can return the following errors.  All these errors
   are represented as XML elements in an XML document, where the
   specific error element appears inside a root element called "error"
   in the "DAV:" namespace.  The new elements defined in this
   specification are all in the "urn:ietf:params:xml:ns:patch"
   namespace.


   delta-encoding-badly-formatted: Used with 400 Bad Request when the
      server finds that the delta encoding provided by the client was
      badly formatted or non-compliant.  The definition of badly
      formatted or non-compliant depends on the delta encoding chosen,
      but generally if the server finds it can't handle the current
      patch even though it supports the format used, this error ought to
      be appropriate.

   delta-encoding-unsupported: Used with 501 Unsupported when the client
      sends a delta encoding that the server doesn't support on this
      resource, or a delta encoding that the server never supports.

   patch-empty-resource: Used with 409 Conflict when the resource
      addressed in the Request-URI exists but is empty, and the delta
      encoding cannot be applied to an empty document.  Note that some
      delta encodings may be applied to an empty document, in which case
      this error wouldn't be used.







Dusseault                Expires April 14, 2005                 [Page 8]


Internet-Draft                 HTTP PATCH                   October 2004


   patch-result-invalid: Used with 409 Conflict when the resource could
      be patched but the result of the patch would be a resource which
      is invalid.  This could mean, for example, that a XML resource
      would become an invalid XML file if the patch specified that a
      close element text line should be deleted.


   "404 Not Found" can be used (with no body/error element) when the URL
   in by the Request-URI does not map to a resource and the server
   cannot apply the delta encoding to a new empty resource.

   Other status codes defined in RFC2616 may also be used under the
   appropriate circumstances, with no response body.  For example, an
   unauthenticated user may be prompted to authenticate, in order to use
   PATCH, with "401 Unauthorized".  An authenticated user who does not
   have sufficient privilege to use PATCH may receive a "403 Forbidden"
   response.

3.2.2.1  Example error response with body detail


       HTTP/1.1 409 Conflict
       Content-Type: text/xml; charset="utf-8"
       Content-Length: xxx

       <?xml version="1.0" encoding="utf-8" ?>
       <D:error xmlns:D="DAV:">
         <P:patch-result-invalid
               xmlns:P="urn:ietf:params:xml:ns:patch"/>
       </D:error>



3.3  Advertising Support in OPTIONS

   The server advertises its support for the features described here
   with OPTIONS response headers.  The "Allow" OPTIONS header is already
   defined in HTTP 1.1  to contain all the allowed methods on the
   addressed resource, so the server MUST add PATCH if it is allowed.

   Clients also need to know whether the server supports special patch
   formats, so this document introduces a new OPTIONS response header
   "Accept-Patch".  "Accept-Patch" MUST appear in the OPTIONS response
   for any resource where the PATCH method is shown as an allowed
   method.

   OPTIONS * is not used to advertise support for PATCH because the
   patch formats supported are likely to change from one resource to



Dusseault                Expires April 14, 2005                 [Page 9]


Internet-Draft                 HTTP PATCH                   October 2004


   another.  A server MAY include the Accept-Patch header in response to
   OPTIONS *, and its value MAY be the union of known supported delta
   encodings for all types of resources.

   Accept-Patch = "Accept-Patch" ":" #instance-manipulation

   Example: OPTIONS request and response for specific resource


       [request]

       OPTIONS /example/buddies.xml HTTP/1.1
       Host: www.example.com

       [response]

       HTTP/1.1 200 OK
       Allow: GET, PUT, POST, OPTIONS, HEAD, TRACE, DELETE, PATCH
       Accept-Patch: vcdiff, gdiff, diffe, example-xcap-xml


   The examples show a server that supports PATCH generally, with all
   the delta encodings defined in RFC3229 plus one fictional
   XML-oriented delta encoding.  On some resources, for example on XML
   files, different kinds of delta encodings more appropriate to the
   resource may be supported.

























Dusseault                Expires April 14, 2005                [Page 10]


Internet-Draft                 HTTP PATCH                   October 2004


4.  Interdependencies with other Standards

4.1  PATCH and Access Control (RFC3744)

   If the server supports WebDAV Access Control [5], then the PATCH
   request SHOULD be subject to the same access control permissions as
   the PUT request.












































Dusseault                Expires April 14, 2005                [Page 11]


Internet-Draft                 HTTP PATCH                   October 2004


5.  IANA Considerations

   This document uses URNs to describe XML namespaces and XML schemas
   conforming to a registry mechanism described in [RFC3688].

   Registration request for the patch namespace:

   URI: urn:ietf:params:xml:ns:patch

   Registrant Contact: See the "Author's Address" section of this
   document.

   XML: None.  Namespace URIs do not represent an XML specification.






































Dusseault                Expires April 14, 2005                [Page 12]


Internet-Draft                 HTTP PATCH                   October 2004


6.  Security Considerations

   The security considerations for PATCH are nearly identical to the
   security considerations for PUT.  In addition, one might be concerned
   that a document that is patched might be more likely to be corrupted,
   but that concern is addressed through use of MD5 digests.













































Dusseault                Expires April 14, 2005                [Page 13]


Internet-Draft                 HTTP PATCH                   October 2004


7.  References

7.1  Normative References

   [1]  Fielding, R., Gettys, J., Mogul, J., Frystyk, H., Masinter, L.,
        Leach, P. and T. Berners-Lee, "Hypertext Transfer Protocol --
        HTTP/1.1", RFC 2616, June 1999.

   [2]  Mogul, J., Krishnamurthy, B., Douglis, F., Feldmann, A., Goland,
        Y., van Hoff, A. and D. Hellerstein, "Delta encoding in HTTP",
        RFC 3229, January 2002.

7.2  Non-Normative References

   [3]  Goland, Y., Whitehead, E., Faizi, A., Carter, S. and D. Jensen,
        "HTTP Extensions for Distributed Authoring -- WEBDAV", RFC 2518,
        February 1999.

   [4]  Clemm, G., Amsden, J., Ellison, T., Kaler, C. and J. Whitehead,
        "Versioning Extensions to WebDAV (Web Distributed Authoring and
        Versioning)", RFC 3253, March 2002.

   [5]  Clemm, G., Reschke, J., Sedlar, E. and J. Whitehead, "Web
        Distributed Authoring and Versioning (WebDAV) Access Control
        Protocol", RFC 3744, May 2004.


Author's Address

   Lisa Dusseault
   Open Source Application Foundation
   2064 Edgewood Dr.
   Palo Alto, CA  94303
   US

   EMail: lisa@osafoundation.org















Dusseault                Expires April 14, 2005                [Page 14]


Internet-Draft                 HTTP PATCH                   October 2004


Appendix A.  Acknowledgements

   PATCH is not a new concept, it first appeared in HTTP in drafts of
   version 1.1 written by Roy Fielding and Henrik Frystyk.

   Thanks to Adam Roach, Chris Sharp, Julian Reschke, Geoff Clemm, Scott
   Lawrence, Jeffrey Mogul, Roy Fielding, Greg Stein, Jim Luther, Alex
   Rousskov, Jamie Lokier, Joe Hildebrand, Mark Nottingham and Michael
   Balloni for review and advice on this document.










































Dusseault                Expires April 14, 2005                [Page 15]


Internet-Draft                 HTTP PATCH                   October 2004


Appendix B.  Changes

B.1  Changes from -00

   OPTIONS support: removed "Patch" header definition and used Allow and
   new "Accept-Patch" headers instead.

   Supported delta encodings: removed vcdiff and diffe as these do not
   have defined MIME types and did not seem to be strongly desired.

   PATCH method definition: Clarified cache behavior.

B.2  Changes from -01

   Removed references to XCAP - not yet a RFC.

   Fixed use of MIME types (this "fix" now obsolete)

   Explained how to use MOVE or COPY in conjunction with PATCH, to
   create a new resource based on an existing resource in a different
   location.

B.3  Changes from -02

   Clarified that MOVE and COPY are really independent of PATCH.

   Clarified when an ETag must change, and when Last-Modified must be
   used.

   Clarified what server should do if both Content-Type and IM headers
   appear in PATCH request.

   Filled in missing reference to DeltaV and ACL RFCs.

   Stopped using 501 Unsupported for unsupported delta encodings.

   Clarified what a static resource is.

   Refixed use of MIME types for patch formats.

   Limited the scope of some restrictions to apply only to usage of
   required diff format.

B.4  Changes from -03

   Various typographical, terminology consistency, and other minor
   clarifications or fixes.




Dusseault                Expires April 14, 2005                [Page 16]


Internet-Draft                 HTTP PATCH                   October 2004


B.5  Changes from -04

   Moved paragraphs on ACL and RFC3229 interoperability to new section.

   Added security considerations.

   Added IANA considerations, registration of new namespace, and
   discontinued use of "DAV:" namespace for new elements.

   Added example of error response.

B.6  Changes from -05

   Due to various concerns it didn't seem likely the application/gdiff
   registration could go through so switching to vcdiff as required diff
   format, and to RFC3229's approach to specifying diff formats,
   including use of the IM header.

   Clarified what header server MUST use to return MD5 hash.

   Reverted to  using 501 Unsupported for unsupported delta encodings.






























Dusseault                Expires April 14, 2005                [Page 17]


Internet-Draft                 HTTP PATCH                   October 2004


Appendix C.  Notes to RFC Editor

   The RFC Editor should remove this section and the Changes section.
















































Dusseault                Expires April 14, 2005                [Page 18]


Internet-Draft                 HTTP PATCH                   October 2004


Intellectual Property Statement

   The IETF takes no position regarding the validity or scope of any
   Intellectual Property Rights or other rights that might be claimed to
   pertain to the implementation or use of the technology described in
   this document or the extent to which any license under such rights
   might or might not be available; nor does it represent that it has
   made any independent effort to identify any such rights.  Information
   on the procedures with respect to rights in RFC documents can be
   found in BCP 78 and BCP 79.

   Copies of IPR disclosures made to the IETF Secretariat and any
   assurances of licenses to be made available, or the result of an
   attempt made to obtain a general license or permission for the use of
   such proprietary rights by implementers or users of this
   specification can be obtained from the IETF on-line IPR repository at
   http://www.ietf.org/ipr.

   The IETF invites any interested party to bring to its attention any
   copyrights, patents or patent applications, or other proprietary
   rights that may cover technology that may be required to implement
   this standard.  Please address the information to the IETF at
   ietf-ipr@ietf.org.


Disclaimer of Validity

   This document and the information contained herein are provided on an
   "AS IS" basis and THE CONTRIBUTOR, THE ORGANIZATION HE/SHE REPRESENTS
   OR IS SPONSORED BY (IF ANY), THE INTERNET SOCIETY AND THE INTERNET
   ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED,
   INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE
   INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED
   WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.


Copyright Statement

   Copyright (C) The Internet Society (2004).  This document is subject
   to the rights, licenses and restrictions contained in BCP 78, and
   except as set forth therein, the authors retain all their rights.


Acknowledgment

   Funding for the RFC Editor function is currently provided by the
   Internet Society.




Dusseault                Expires April 14, 2005                [Page 19]