Re: HTTP Content-Location header usage

Mark Nottingham <mnot@mnot.net> Mon, 17 October 2016 03:30 UTC

Return-Path: <ietf-http-wg-request+bounce-httpbisa-archive-bis2juki=lists.ie@listhub.w3.org>
X-Original-To: ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com
Delivered-To: ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 6ABAA129570 for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Sun, 16 Oct 2016 20:30:11 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -7.332
X-Spam-Level:
X-Spam-Status: No, score=-7.332 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.001, RCVD_IN_DNSWL_HI=-5, RP_MATCHES_RCVD=-0.431, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8ba0mM_Mky0W for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Sun, 16 Oct 2016 20:30:09 -0700 (PDT)
Received: from frink.w3.org (frink.w3.org [128.30.52.56]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id D3FA2129565 for <httpbisa-archive-bis2Juki@lists.ietf.org>; Sun, 16 Oct 2016 20:30:09 -0700 (PDT)
Received: from lists by frink.w3.org with local (Exim 4.80) (envelope-from <ietf-http-wg-request@listhub.w3.org>) id 1bvyYX-0002mT-BE for ietf-http-wg-dist@listhub.w3.org; Mon, 17 Oct 2016 03:25:41 +0000
Resent-Date: Mon, 17 Oct 2016 03:25:41 +0000
Resent-Message-Id: <E1bvyYX-0002mT-BE@frink.w3.org>
Received: from maggie.w3.org ([128.30.52.39]) by frink.w3.org with esmtps (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from <mnot@mnot.net>) id 1bvyYS-0002li-3f for ietf-http-wg@listhub.w3.org; Mon, 17 Oct 2016 03:25:36 +0000
Received: from mxout-07.mxes.net ([216.86.168.182]) by maggie.w3.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from <mnot@mnot.net>) id 1bvyYO-0000Hd-9e for ietf-http-wg@w3.org; Mon, 17 Oct 2016 03:25:35 +0000
Received: from [192.168.3.104] (unknown [124.189.98.244]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.mxes.net (Postfix) with ESMTPSA id A61A222E1FA; Sun, 16 Oct 2016 23:25:07 -0400 (EDT)
Content-Type: text/plain; charset=utf-8
Mime-Version: 1.0 (Mac OS X Mail 10.0 \(3226\))
From: Mark Nottingham <mnot@mnot.net>
In-Reply-To: <CAGnWK0Rg1Md9tTof9uZqjmwqas2Vo2nktcGLtNUY4g-JMq+ZZA@mail.gmail.com>
Date: Mon, 17 Oct 2016 14:25:04 +1100
Cc: HTTP working group mailing list <ietf-http-wg@w3.org>
Content-Transfer-Encoding: quoted-printable
Message-Id: <9E6EE6D9-8907-4C4B-A890-E99CC920F871@mnot.net>
References: <CAGnWK0SnbuXk69jaWm8PY88G7pyVx1zKkY9Och6SApeVJjhQBw@mail.gmail.com> <8AAD31B4-0F30-46F3-AA19-AE136FD7066F@mnot.net> <CAGnWK0Rg1Md9tTof9uZqjmwqas2Vo2nktcGLtNUY4g-JMq+ZZA@mail.gmail.com>
To: Nikita Piskunov <n.piskunov91@gmail.com>
X-Mailer: Apple Mail (2.3226)
Received-SPF: pass client-ip=216.86.168.182; envelope-from=mnot@mnot.net; helo=mxout-07.mxes.net
X-W3C-Hub-Spam-Status: No, score=-8.4
X-W3C-Hub-Spam-Report: AWL=1.247, BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, W3C_AA=-1, W3C_DB=-1, W3C_IRA=-1, W3C_IRR=-3, W3C_WL=-1
X-W3C-Scan-Sig: maggie.w3.org 1bvyYO-0000Hd-9e 2b0d878c2c4692d65dd9eac8ce9141e1
X-Original-To: ietf-http-wg@w3.org
Subject: Re: HTTP Content-Location header usage
Archived-At: <http://www.w3.org/mid/9E6EE6D9-8907-4C4B-A890-E99CC920F871@mnot.net>
Resent-From: ietf-http-wg@w3.org
X-Mailing-List: <ietf-http-wg@w3.org> archive/latest/32610
X-Loop: ietf-http-wg@w3.org
Resent-Sender: ietf-http-wg-request@w3.org
Precedence: list
List-Id: <ietf-http-wg.w3.org>
List-Help: <http://www.w3.org/Mail/>
List-Post: <mailto:ietf-http-wg@w3.org>
List-Unsubscribe: <mailto:ietf-http-wg-request@w3.org?subject=unsubscribe>

Hi,

Sorry for the delay. This one is a bit confusing.

"""
Successful PATCH response to existing text file:

   HTTP/1.1 204 No Content
   Content-Location: /file.txt
   ETag: "e0023aa4f"

The 204 response code is used because the response does not carry a message body (which a response with the 200 code would have).  Note that other success codes could be used as well.
""" - <http://httpwg.org/specs/rfc5789.html#rfc.section.2.1>

At first glance, it seems like this is a bug (assuming that the example isn't about a PATCH that leads to a zero-length response), because Content-Location is defined in terms of the message payload:

"""
If Content-Location is included in a 2xx (Successful) response message and its value refers (after conversion to absolute form) to a URI that is the same as the effective request URI, then the recipient MAY consider the payload to be a current representation of that resource at the time indicated by the message origination date. 
"" - <http://httpwg.org/specs/rfc7231.html#header.content-location>

However, 204 is defined with this clause:

"""
Metadata in the response header fields refer to the target resource and its selected representation after the requested action was applied.

For example, if a 204 status code is received in response to a PUT request and the response contains an ETag header field, then the PUT was successful and the ETag field-value contains the entity-tag for the new representation of that target resource.
""" - <http://httpwg.org/specs/rfc7231.html#status.204>

Giving precedence to the higher-level semantics of the status code, the Content-Location now applies to the selected representation (i.e., what the response would have contained, had the response been a 200 -- see <http://httpwg.org/specs/rfc7231.html#representations>), *not* the payload in the actual message.

Does that make sense?

I think RFC5987 and RFC7231 could be clearer about this, but I'm not sure it merits an errata. We should probably create an issue to track it for the next revision of these documents, though.

Cheers,



> On 28 Sep. 2016, at 7:49 pm, Nikita Piskunov <n.piskunov91@gmail.com> wrote:
> 
> Mark, thank you for the reply, but my main confusion is about the second part of my letter. I understand, that Content-Location header can be a link to another URL, representing the current resource in the http-response body in this reponse. But, what about the responses with 204 status code (No-Content). They can't have a body in general, so they have no representation of the current resource. But we can find the example of http-response in RFC 5789, which has 204 status and includes Content-Location header. In other words:
> 
> If I perform:
> 
>       PATCH http://tempuri.org/myresource/id123,
>       Content-type: appllication/json
>       Body: {"Foo":"Bar"}
> 
> The possible response is:
> 
>       HTTP/1.1 200 Ok
>       Content-Location: http://tempuri.org/alsomyresource/id111
>       Content-type: appllication/json
>       Body: {"Foo": "Bar"}
> 
> But, is it possible to respond in this way (how we can see in RFC 5789) - with no body, and Content-Location?
> 
>       HTTP/1.1 204 No Content
>       Content-Location: http://tempuri.org/alsomyresource/id111
> 
> In my opinion, the description of Content-Location header usage in RFC 7231 and example in RFC 5789 contradict each other.
> 
> 2016-09-28 9:10 GMT+03:00 Mark Nottingham <mnot@mnot.net>et>:
> 
> > On 21 Sep. 2016, at 10:35 pm, Никита Пискунов <n.piskunov91@gmail.com> wrote:
> >
> > Hello,
> > i've already posted my comment about ambiguous Content-Location header usage description here as a GitHub Issue. And I've also decided to raise the discussion via email.
> >
> > So, my question is:
> >
> > The RFC 5789 discribes the apropriate usage of Content-Location header in PATCH:
> >
> > A response to this method is only cacheable if it contains explicit freshness information (such as an Expires header or "Cache-Control: max-age" directive) as well as the Content-Location header matching the Request-URI, indicating that the PATCH response body is a resource representation.
> > So, it means, that Content-Location header must appear only if the actual represantation is the part of response body for PATCH.
> 
> No. Content-Location can appear; it indicates a URL for the representation in the message. *If* it matches the request-target, you can deduce that it's a representation of what's currently at that resource (after the PATCH is applied). But if it doesn't match, it can still appear.
> 
> > Also the usage of Content-Location is mentioned in another RFC 7231:
> >
> > For a state-changing request like PUT (Section 4.3.4) or POST (Section 4.3.3), it implies that the server's response contains the new representation of that resource, thereby distinguishing it from representations that might only report about the action (e.g., "It worked!"). This allows authoring applications to update their local copies without the need for a subsequent GET request.
> > So, accordingly to this information in both RFCs, the apropriate usage of Content-Location with state-changing requests are following:
> > Content-Location must appear in response only if response-body contains the new resourse representation.
> >
> > But, there is also an example in RFC 5789:
> >
> > Successful PATCH response to existing text file:
> >
> > HTTP/1.1 204 No Content
> > Content-Location: /file.txt
> > ETag: "e0023aa4f"
> >
> > The 204 response code is used because the response does not carry a message body (which a response with the 200 code would have). Note that other success codes could be used as well.
> >
> > Furthermore, the ETag response header field contains the ETag for the entity created by applying the PATCH, available at http://www.example.com/file.txt, as indicated by the Content-Location response header field.
> > How you can see, there is a Content-Location presented in response with 204 status code (No content). Ofcourse, this response doesn't contain any body as well as new resourse representation. This fact adds some ambiguity in Content-Location header description. What is the correct usage of this header?
> >
> 
> --
> Mark Nottingham   https://www.mnot.net/
> 
> 

--
Mark Nottingham   https://www.mnot.net/