Ignore:
Timestamp:
Mar 10, 2011, 12:40:45 AM (9 years ago)
Author:
fielding@…
Message:

Replaced the general prohibition on unrecognized Content-* header fields
with a specific prohibition of Content-Range (the only field for which
it is an actual problem) and a general requirement regarding checking
for consistency. Unfortunately, this required rewriting the entire
section on PUT to get rid of the misconceptions about storing resources
and reflect how PUT is actually implemented in practice.

Addresses #79, #102, #103, #104, #112, #180, #231, and #267

File:
1 edited

Legend:

Unmodified
Added
Removed
  • draft-ietf-httpbis/latest/p2-semantics.xml

    r1154 r1158  
    10471047  <iref primary="true" item="Methods" subitem="PUT" x:for-anchor=""/>
    10481048<t>
    1049    The PUT method requests that the enclosed representation be stored at the
    1050    effective request URI. If the effective request URI refers to an already
    1051    existing resource, the enclosed representation &SHOULD; be considered a
    1052    modified version of the one residing on the origin server. Otherwise, if the
    1053    effective request URI does not point to an existing resource, and that URI is
    1054    capable of being defined as a new resource by the requesting user
    1055    agent, the origin server can create the resource with that URI.
     1049   The PUT method is used to request that the state of the target resource
     1050   be created or replaced with the state defined by the representation
     1051   enclosed in the request message payload.  A successful PUT of a given
     1052   representation would suggest that a subsequent GET on that same target
     1053   resource will result in an equivalent representation being returned in
     1054   a 200 (OK) response.  However, there is no guarantee that such a state
     1055   change will be observable, since the target resource might be acted
     1056   upon by other user agents in parallel, or might be subject to dynamic
     1057   processing by the origin server, before any subsequent GET is received.
     1058   A successful response only implies that the user agent's intent was
     1059   achieved at the time of its processing by the origin server.
    10561060</t>
    10571061<t>   
    1058    If a new resource is created at the effective request URI, the origin
    1059    server &MUST; inform the user agent
    1060    via the 201 (Created) response. If an existing resource is modified,
    1061    either the 200 (OK) or 204 (No Content) response codes &SHOULD; be sent
    1062    to indicate successful completion of the request.
    1063 </t>
    1064 <t>   
    1065    If the target resource could not be created or modified, an appropriate
    1066    error response &SHOULD; be given that reflects the nature of the problem.
    1067    The recipient of the representation &MUST-NOT; ignore any Content-*
    1068    header fields (headers starting with the prefix "Content-") that it does
    1069    not understand or implement
    1070    and &MUST; return a 501 (Not Implemented) response in such cases.
     1062   If the target resource does not have a current representation and
     1063   the PUT successfully creates one, then the origin server &MUST; inform
     1064   the user agent by sending a 201 (Created) response.  If the target
     1065   resource does have a current representation and that representation is
     1066   successfully modified in accordance with the state of the enclosed
     1067   representation, then either a 200 (OK) or 204 (No Content) response
     1068   &SHOULD; be sent to indicate successful completion of the request.
     1069</t>
     1070<t>
     1071   Unrecognized header fields &SHOULD; be ignored (i.e., not saved
     1072   as part of the resource state).
     1073</t>
     1074<t>
     1075   An origin server &SHOULD; verify that the PUT representation is
     1076   consistent with any constraints which the server has for the target
     1077   resource that cannot or will not be changed by the PUT.  This is
     1078   particularly important when the origin server uses internal
     1079   configuration information related to the URI in order to set the
     1080   values for representation metadata on GET responses.  When a PUT
     1081   representation is inconsistent with the target resource, the origin
     1082   server &SHOULD; either make them consistent, by transforming the
     1083   representation or changing the resource configuration, or respond
     1084   with a 409 (Conflict) status code and sufficient information
     1085   to explain why the representation is unsuitable.
     1086</t>
     1087<t>
     1088   For example, if the target resource is configured to always have a
     1089   Content-Type of "text/html" and the representation being PUT has a
     1090   Content-Type of "image/jpeg", then the origin server &SHOULD; do one of:
     1091   (a) reconfigure the target resource to reflect the new media type;
     1092   (b) transform the PUT representation to a format consistent with that
     1093   of the resource before saving it as the new resource state; or,
     1094   (c) reject the request with a 409 response indicating that the target
     1095   resource is limited to "text/html", perhaps including a link to a
     1096   different resource that would be a suitable target for the new
     1097   representation.
     1098</t>
     1099<t>
     1100   HTTP does not define exactly how a PUT method affects the state
     1101   of an origin server beyond what can be expressed by the intent of
     1102   the user agent request and the semantics of the origin server response.
     1103   It does not define what a resource might be, in any sense of that
     1104   word, beyond the interface provided via HTTP.  It does not define
     1105   how resource state is "stored", nor how such storage might change
     1106   as a result of a change in resource state, nor how the origin server
     1107   translates resource state into representations.  Generally speaking,
     1108   all implementation details behind the resource interface are
     1109   intentionally hidden by the server.
     1110</t>
     1111<t>
     1112   The fundamental difference between the POST and PUT methods is
     1113   highlighted by the different intent for the target resource.
     1114   The target resource in a POST request is intended to handle the
     1115   enclosed representation as a data-accepting process, such as for
     1116   a gateway to some other protocol or a document that accepts annotations.
     1117   In contrast, the target resource in a PUT request is intended to
     1118   take the enclosed representation as a new or replacement value.
     1119   Hence, the intent of PUT is idempotent and visible to intermediaries,
     1120   even though the exact effect is only known by the origin server.
     1121</t>
     1122<t>
     1123   Proper interpretation of a PUT request presumes that the user agent
     1124   knows what target resource is desired.  A service that is intended
     1125   to select a proper URI on behalf of the client, after receiving
     1126   a state-changing request, &SHOULD; be implemented using the POST
     1127   method rather than PUT.  If the origin server will not make the
     1128   requested PUT state change to the target resource and instead
     1129   wishes to have it applied to a different resource, such as when the
     1130   resource has been moved to a different URI, then the origin server
     1131   &MUST; send a 301 (Moved Permanently) response; the user agent &MAY;
     1132   then make its own decision regarding whether or not to redirect the
     1133   request.
     1134</t>
     1135<t>
     1136   A PUT request applied to the target resource &MAY; have side-effects
     1137   on other resources.  For example, an article might have a URI for
     1138   identifying "the current version" (a resource) which is separate
     1139   from the URIs identifying each particular version (different
     1140   resources that at one point shared the same state as the current version
     1141   resource).  A successful PUT request on "the current version" URI might
     1142   therefore create a new version resource in addition to changing the
     1143   state of the target resource, and might also cause links to be added
     1144   between the related resources.
     1145</t>
     1146<t>
     1147   An origin server &SHOULD; reject any PUT request that contains a
     1148   Content-Range header field, since it might be misinterpreted as
     1149   partial content (or might be partial content that is being mistakenly
     1150   PUT as a full representation).  Partial content updates are
     1151   possible by targeting a separately identified resource with state
     1152   that overlaps a portion of the larger resource, or by using a
     1153   different method that has been specifically defined for partial
     1154   updates (for example, the PATCH method defined in
     1155   <xref target="RFC5789"/>).
    10711156</t>
    10721157<t>
     
    10751160   request URI, those stored responses will be invalidated (see
    10761161   &p6-invalid;).
    1077 </t>
    1078 <t>
    1079    The fundamental difference between the POST and PUT requests is
    1080    reflected in the different meaning of the effective request URI. The URI in a
    1081    POST request identifies the resource that will handle the enclosed
    1082    representation. That resource might be a data-accepting process, a gateway to
    1083    some other protocol, or a document that accepts annotations.
    1084    In contrast, the URI in a PUT request identifies the resource for
    1085    which enclosed representation is a new or replacement value; the
    1086    user agent knows what URI is intended and the server &MUST-NOT; attempt
    1087    to apply the request to some other resource.
    1088    If the server desires that the request be applied to a different URI,
    1089    it &MUST; send a 301 (Moved Permanently) response; the user agent &MAY;
    1090    then make its own decision regarding whether or not to redirect the
    1091    request.
    1092 </t>
    1093 <t>
    1094    A single resource &MAY; be identified by many different URIs. For
    1095    example, an article might have a URI for identifying "the current
    1096    version" which is separate from the URI identifying each particular
    1097    version. In this case, a PUT request on a general URI might result in
    1098    several other URIs being defined by the origin server.
    1099 </t>
    1100 <t>
    1101    HTTP/1.1 does not define how a PUT method affects the state of an
    1102    origin server.
    1103 </t>
    1104 <t>
    1105    Header fields in a PUT request that are recognized as representation
    1106    metadata &SHOULD; be applied to the resource created or modified by
    1107    the PUT.  Unrecognized header fields &SHOULD; be ignored.
    11081162</t>
    11091163</section>
     
    34713525  </front>
    34723526  <seriesInfo name="RFC" value="5322"/>
     3527</reference>
     3528
     3529<reference anchor='RFC5789'>
     3530  <front>
     3531    <title>PATCH Method for HTTP</title>
     3532    <author initials='L.' surname='Dusseault' fullname='L. Dusseault'>
     3533      <organization>Linden Lab</organization>
     3534    </author>
     3535    <author initials='J.' surname='Snell' fullname='J. Snell'>
     3536      <organization />
     3537    </author>
     3538    <date year='2010' month='March' />
     3539  </front>
     3540  <seriesInfo name='RFC' value='5789' />
    34733541</reference>
    34743542
Note: See TracChangeset for help on using the changeset viewer.