1. HTTP (Hypertext Transfer Protocol)

  1. HTTP Headers

  1. Content-Location
    1. Writing requests (clients)
    2. Reading requests (servers)
    3. Writing responses (servers)
    4. Reading responses (clients)
    5. Overview table
    6. Syntax
      1. Example
    7. History

Content-Location

The Content-Location header specifies the URI of the selected representation. It is used when the request-URI can negotiate to one of several representations, or when a server wants to indicate that the message body of a response (e.g. a POST) is available for retreival at the given URI.

Writing requests (clients)

Usage of the Content-Location header in requests is technically legal, but since the server is the final authority of its URI namespace, behavior in requests is undefined.

Reading requests (servers)

The Content-Location header in requests should be ignored, unless the server has something to gain by a client's assertion that the request-body is also available at another URI.

Writing responses (servers)

The Content-Location header should be used in the following responses:

  • GET/HEAD requests that have multiple alternative representations, and a representation was selected by the server after Content-Type negotiation
  • The server accepted a PUT request, or other request that modified a resource; then normalized or otherwise modified the resource; and so the server responded with the new/modified version

Reading responses (clients)

The Content-Location header may be a URI Reference, which is resolved relative to the request-URI.

If the client wants to bookmark the selected variant, it should save the Content-Location URI instead of the request-URI.

If the server returns a Content-Location of the request-URI in a PUT or similar request, it means the representation was potentially modified by the server from what the client sent, and the server is attaching the new representation for reference.

Caching headers apply to the request-URI, not the Content-Location, and caches cannot populate an entry at the Content-Location with the response. Caches could potentially use the Content-Location header to invalidate a cache entry.

Overview table

Name
Content-Location
Direction
Both
Description
Specifies a URI that the message body is available at.
Specification
RFC 7231: HTTP/1.1 Semantics and Content ยง3.1.4.2. Content-Location

Syntax

Content-Location = absolute-URI / partial-URI

Example

HTTP/1.1 200 OK
Date: Thu, 16 May 2112 18:51:10 GMT
Content-Location: http://example.com/index.html

History

RFC2616 defined the Content-Location header as able to set the base URI for the document. User agents did not typically implement this, and this aspect was removed in RFC7231. Many hypermedia types, including HTML (by the "base" element), have similar features that are implemented by user agents, and these should be used instead.