Individual Submission                                       L. Dusseault
Internet-Draft                                                      OSAF
Expires: December 24, 2007                                      J. Snell
                                                           June 22, 2007

                         PATCH Method for HTTP

Status of this Memo

   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 becomes
   aware will be disclosed, in accordance with Section 6 of BCP 79.

   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-

   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

   The list of Internet-Draft Shadow Directories can be accessed at

   This Internet-Draft will expire on December 24, 2007.

Copyright Notice

   Copyright (C) The IETF Trust (2007).

Dusseault & Snell       Expires December 24, 2007               [Page 1]

Internet-Draft                 HTTP PATCH                      June 2007


   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.

Table of Contents

   1.  Introduction . . . . . . . . . . . . . . . . . . . . . . . . .  3
   2.  Mechanisms . . . . . . . . . . . . . . . . . . . . . . . . . .  4
     2.1.  PATCH Method . . . . . . . . . . . . . . . . . . . . . . .  4
     2.2.  PATCH Response . . . . . . . . . . . . . . . . . . . . . .  5
       2.2.1.  Success Response . . . . . . . . . . . . . . . . . . .  5
       2.2.2.  Error handling . . . . . . . . . . . . . . . . . . . .  5
     2.3.  Advertising Support in OPTIONS . . . . . . . . . . . . . .  7
   3.  Delta Encodings  . . . . . . . . . . . . . . . . . . . . . . .  9
   4.  IANA Considerations  . . . . . . . . . . . . . . . . . . . . . 10
   5.  Security Considerations  . . . . . . . . . . . . . . . . . . . 11
   6.  Normative References . . . . . . . . . . . . . . . . . . . . . 12
   Appendix A.  Acknowledgements  . . . . . . . . . . . . . . . . . . 13
   Appendix B.  Changes . . . . . . . . . . . . . . . . . . . . . . . 14
     B.1.  Changes from -00 . . . . . . . . . . . . . . . . . . . . . 14
     B.2.  Changes from -01 . . . . . . . . . . . . . . . . . . . . . 14
     B.3.  Changes from -02 . . . . . . . . . . . . . . . . . . . . . 14
     B.4.  Changes from -03 . . . . . . . . . . . . . . . . . . . . . 14
     B.5.  Changes from -04 . . . . . . . . . . . . . . . . . . . . . 15
     B.6.  Changes from -05 . . . . . . . . . . . . . . . . . . . . . 15
     B.7.  Changes from -06 . . . . . . . . . . . . . . . . . . . . . 15
   Appendix C.  Notes to RFC Editor . . . . . . . . . . . . . . . . . 16
   Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 17
   Intellectual Property and Copyright Statements . . . . . . . . . . 18

Dusseault & Snell       Expires December 24, 2007               [Page 2]

Internet-Draft                 HTTP PATCH                      June 2007

1.  Introduction

   This specification defines a new HTTP 1.1 [1] method PATCH that is
   used to apply partial modifications 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
   would not confuse caching proxies.

Dusseault & Snell       Expires December 24, 2007               [Page 3]

Internet-Draft                 HTTP PATCH                      June 2007

2.  Mechanisms

2.1.  PATCH Method

   The PATCH method requests that a set of changes described in the
   request entity be applied to the resource identified by the Request-
   URI.  The set of changes is represented in a format called a "delta
   encoding" identified by a media type and MUST include sufficient
   information to allow the server to recreate the changes necessary to
   convert the original version of the resource into the desired
   version.  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 resource.  The recipient
   of the entity MUST NOT ignore any Content-* (e.g.  Content-Range)
   headers that it does not understand or implement and MUST return a
   501 (Not Implemented) response in such cases.

   The server SHOULD 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 delta encoding 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.

   The actual method for determining how to apply the delta encoding to
   the resource is defined entirely by the origin server.

   If the request passes through a cache and the Request-URI identifies
   one or more currently cached entities, those entries SHOULD be
   treated as stale.  Responses to this method are not cacheable.

   Collisions from multiple requests are more dangerous than PUT
   collisions, because a delta encoding that is not operating from a
   known base point may corrupt the resource.  Therefore, the client
   MUST verify that it is applying the delta encoding to a known entity
   by first acquiring the strong ETag of the resource to be modified,
   and using that Etag in the If-Match header on the PATCH request to
   make sure the resource is still unchanged.  If a strong ETag is not
   available for a given resource, the client MUST use If-Unmodified-
   Since as a less-reliable safeguard.

   Servers SHOULD provide strong ETags for all resources for which the
   PATCH method is supported.

   Servers advertise the types of delta encoding documents supported for
   PATCH, and clients specify which one they're using by including its
   media type in the request using the Content-Type request header.

Dusseault & Snell       Expires December 24, 2007               [Page 4]

Internet-Draft                 HTTP PATCH                      June 2007

   Simple PATCH example

       PATCH /file.txt HTTP/1.1
       Content-type: application/delta
       If-Match: "e0023aa4e"
       Content-Length: 100

       [description of changes]

                                 Figure 1

   This example illustrates use of a hypothetical delta encoding on an
   existing text file.

2.2.  PATCH Response

2.2.1.  Success Response

   A response with a 2xx status code indicates that the PATCH request
   was a success.  The server MAY include a representation of the
   modified resource in the response and MAY include appropriate
   Content-* headers to allow the client to verify the success of the

   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 200 OK
       ETag: "e0023aa4f"
       Content-MD5: Q2hlY2sgSW50ZWdyaXR5IQ==
       Content-Type: text/plain

       [modified resource]

2.2.2.  Error handling

   There are several known conditions under which a PATCH request can

Dusseault & Snell       Expires December 24, 2007               [Page 5]

Internet-Draft                 HTTP PATCH                      June 2007

   Malformed Delta Encoding:  Specified using a 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.

   Unsupported Delta Encoding:  Specified using a 415 Unsupported Media
      Type when the client sends a delta encoding that the server
      doesn't support for the resource identified by the Request-URI.
      Such a response SHOULD include an Accept-Patch response header as
      described in Section 2.3 to notify the client what delta encoding
      formats are supported.

   Patch Conflict:  Specified with a 409 Conflict when the server
      understands the delta encoding and the delta encoding looks valid,
      but it cannot be applied to the resource.  There are a number of
      ways the resource could conflict with the delta encoding, for

      *  The client attempted to apply a delta encoding to an empty
         file, but the delta encoding chosen cannot be applied to an
         empty file.

      *  The client attempted to apply a structural delta algorithm and
         the structures assumed to exist didn't exist (e.g. an XML delta
         which specifies changing element 'foo' to element 'bar' but
         element 'foo' doesn't exist).

   Concurrent modification:  Specified with a 412 Precondition Failed
      when a client attempts to apply a delta encoding to a resource
      whose state has changed since the delta encoding was created.

   Invalid Result:  Specified with a 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.

   Other status codes MAY also be used under the appropriate
   circumstances.  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.

   The entity body of error responses SHOULD contain enough information

Dusseault & Snell       Expires December 24, 2007               [Page 6]

Internet-Draft                 HTTP PATCH                      June 2007

   to communicate the nature of the error to the client.  The content-
   type of the response entity can vary across implementations.  XML
   error responses as defined by [RFC2518bis] MAY be used.  Example error response with body detail

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

       Invalid result

2.3.  Advertising Support in OPTIONS

   The server advertises its support for the PATCH method 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 specific delta
   encoding formats, so this document introduces a new response header
   "Accept-Patch" used to specify the delta encoding formats accepted by
   the server.  "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
   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" ":" #( media-range )

   The Accept-Patch header specifies a listing of media ranges as
   defined by RFC2616 Section 14.1.  Note that, unlike the HTTP Accept
   request header, the Accept-Patch header does not use quality factors.

Dusseault & Snell       Expires December 24, 2007               [Page 7]

Internet-Draft                 HTTP PATCH                      June 2007

   Example: OPTIONS request and response for specific resource


       OPTIONS /example/buddies.xml HTTP/1.1


       HTTP/1.1 200 OK
       Accept-Patch: application/diff, application/diff+xml

   The examples show a server that supports PATCH generally using two
   hypothetical delta encodings.

Dusseault & Snell       Expires December 24, 2007               [Page 8]

Internet-Draft                 HTTP PATCH                      June 2007

3.  Delta Encodings

   There is no guarantee that a resource can be modified with PATCH.
   Further, it is expected that different delta encodings will be
   appropriate for different types of resources and that no single delta
   encoding will be appropriate for all types of resources.  Therefore,
   there is no single default delta encoding that implementations are
   required to support.  Servers MUST ensure that a received delta
   encoding is appropriate for the type of resource identified by the

   Byte-based or binary delta encodings are useful for many types of
   resources as long as the server stores resources identically to the
   way they're presented on the wire (or can behave as if it does).

   Character-based delta encodings operate on a variable number of bytes
   depending on the length of each character, thus correct use of these
   algorithms depends on the encoding of the resource.  Such delta
   encodings MUST either use the same character set encoding as the
   resource being modified or MUST produce an otherwise valid result.
   The validity of the result is dependent on the type of resource being

   Structure-based delta encodings allow changes to be applied
   independent of exact formats or canonicalizations.  For example, a
   delta encoding format targeted at the modification of XML-based
   resources may allow for the insertion or deletion of elements and
   attributes without concern for the exact serialization of those in
   the modified resource.

Dusseault & Snell       Expires December 24, 2007               [Page 9]

Internet-Draft                 HTTP PATCH                      June 2007

4.  IANA Considerations

   This document does not specify any actions for IANA.

Dusseault & Snell       Expires December 24, 2007              [Page 10]

Internet-Draft                 HTTP PATCH                      June 2007

5.  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 can be addressed through the use of mechanisms such
   as conditional requests using ETags and the If-Match request header.

   Sometimes an HTTP intermediary might try to detect viruses being sent
   via HTTP by checking the body of the PUT/POST request or GET
   response.  The PATCH method complicates such watch-keeping because
   neither the source document nor the patch document might be a virus,
   yet the result could be.  This security consideration is not
   materially different from those already introduced by byte-range
   downloads, downloading patch documents, uploading zipped (compressed)
   files and so on.

   Individual delta encodings will have their own specific security
   considerations that will likely vary depending on the types of
   resources being patched.  The considerations for patched binary
   resources, for instance, will be different than those for patched XML

Dusseault & Snell       Expires December 24, 2007              [Page 11]

Internet-Draft                 HTTP PATCH                      June 2007

6.  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.

Dusseault & Snell       Expires December 24, 2007              [Page 12]

Internet-Draft                 HTTP PATCH                      June 2007

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 & Snell       Expires December 24, 2007              [Page 13]

Internet-Draft                 HTTP PATCH                      June 2007

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

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

   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 & Snell       Expires December 24, 2007              [Page 14]

Internet-Draft                 HTTP PATCH                      June 2007

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.

B.7.  Changes from -06

   The reliance on RFC 3229 defined delta encodings has been factored
   out in favor of delta encodings identified by MIME media type.

   The required use of DeltaV-based error reporting has been removed in
   favor of using basic HTTP status codes to report error conditions.

   The Accept-Patch response header has been redefined as a listing of
   media-ranges with quality factors, similar to the Accept request

   Added James Snell as a co-author.

Dusseault & Snell       Expires December 24, 2007              [Page 15]

Internet-Draft                 HTTP PATCH                      June 2007

Appendix C.  Notes to RFC Editor

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

Dusseault & Snell       Expires December 24, 2007              [Page 16]

Internet-Draft                 HTTP PATCH                      June 2007

Authors' Addresses

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


   James M Snell


Dusseault & Snell       Expires December 24, 2007              [Page 17]

Internet-Draft                 HTTP PATCH                      June 2007

Full Copyright Statement

   Copyright (C) The IETF Trust (2007).

   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.

   This document and the information contained herein are provided on an

Intellectual Property

   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

   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


   Funding for the RFC Editor function is provided by the IETF
   Administrative Support Activity (IASA).

Dusseault & Snell       Expires December 24, 2007              [Page 18]