draft-ietf-httpbis-bcp56bis-09.txt   draft-ietf-httpbis-bcp56bis-latest.txt 
HTTP Working Group M. Nottingham HTTP Working Group M. Nottingham
Internet-Draft October 31, 2019 Internet-Draft March 2, 2021
Obsoletes: 3205 (if approved) Obsoletes: 3205 (if approved)
Intended status: Best Current Practice Intended status: Best Current Practice
Expires: May 3, 2020 Expires: September 3, 2021
Building Protocols with HTTP Building Protocols with HTTP
draft-ietf-httpbis-bcp56bis-09 draft-ietf-httpbis-bcp56bis-latest
Abstract Abstract
HTTP is often used as a substrate for other application protocols HTTP is often used as a substrate for other application protocols to
(a.k.a. HTTP-based APIs). This document specifies best practices create HTTP-based APIs. This document specifies best practices for
for writing specifications that use HTTP to define new application writing specifications that use HTTP to define new application
protocols, especially when they are defined for diverse protocols, especially when they are defined for diverse
implementation and broad deployment (e.g., in standards efforts). implementation and broad deployment (e.g., in standards efforts).
Note to Readers Note to Readers
_RFC EDITOR: please remove this section before publication_
Discussion of this draft takes place on the HTTP working group Discussion of this draft takes place on the HTTP working group
mailing list (ietf-http-wg@w3.org), which is archived at mailing list (ietf-http-wg@w3.org), which is archived at
https://lists.w3.org/Archives/Public/ietf-http-wg/ [1]. https://lists.w3.org/Archives/Public/ietf-http-wg/ [1].
Working Group information can be found at http://httpwg.github.io/ Working Group information can be found at http://httpwg.github.io/
[2]; source code and issues list for this draft can be found at [2]; source code and issues list for this draft can be found at
https://github.com/httpwg/http-extensions/labels/bcp56bis [3]. https://github.com/httpwg/http-extensions/labels/bcp56bis [3].
Status of This Memo Status of This Memo
skipping to change at page 1, line 45 skipping to change at page 1, line 47
Internet-Drafts are working documents of the Internet Engineering Internet-Drafts are working documents of the Internet Engineering
Task Force (IETF). Note that other groups may also distribute Task Force (IETF). Note that other groups may also distribute
working documents as Internet-Drafts. The list of current Internet- working documents as Internet-Drafts. The list of current Internet-
Drafts is at https://datatracker.ietf.org/drafts/current/. Drafts is at https://datatracker.ietf.org/drafts/current/.
Internet-Drafts are draft documents valid for a maximum of six months Internet-Drafts are draft documents valid for a maximum of six months
and may be updated, replaced, or obsoleted by other documents at any and may be updated, replaced, or obsoleted by other documents at any
time. It is inappropriate to use Internet-Drafts as reference time. It is inappropriate to use Internet-Drafts as reference
material or to cite them other than as "work in progress." material or to cite them other than as "work in progress."
This Internet-Draft will expire on May 3, 2020. This Internet-Draft will expire on September 3, 2021.
Copyright Notice Copyright Notice
Copyright (c) 2019 IETF Trust and the persons identified as the Copyright (c) 2021 IETF Trust and the persons identified as the
document authors. All rights reserved. document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents Provisions Relating to IETF Documents
(https://trustee.ietf.org/license-info) in effect on the date of (https://trustee.ietf.org/license-info) in effect on the date of
publication of this document. Please review these documents publication of this document. Please review these documents
carefully, as they describe your rights and restrictions with respect carefully, as they describe your rights and restrictions with respect
to this document. Code Components extracted from this document must to this document. Code Components extracted from this document must
include Simplified BSD License text as described in Section 4.e of include Simplified BSD License text as described in Section 4.e of
the Trust Legal Provisions and are provided without warranty as the Trust Legal Provisions and are provided without warranty as
described in the Simplified BSD License. described in the Simplified BSD License.
Table of Contents
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3
1.1. Notational Conventions . . . . . . . . . . . . . . . . . 4
2. Is HTTP Being Used? . . . . . . . . . . . . . . . . . . . . . 4
2.1. Non-HTTP Protocols . . . . . . . . . . . . . . . . . . . 5
3. What's Important About HTTP . . . . . . . . . . . . . . . . . 5
3.1. Generic Semantics . . . . . . . . . . . . . . . . . . . . 5
3.2. Links . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.3. Rich Functionality . . . . . . . . . . . . . . . . . . . 7
4. Best Practices for Specifying the Use of HTTP . . . . . . . . 8
4.1. Specifying the Use of HTTP . . . . . . . . . . . . . . . 8
4.2. Specifying Server Behaviour . . . . . . . . . . . . . . . 9
4.3. Specifying Client Behaviour . . . . . . . . . . . . . . . 10
4.4. Specifying URLs . . . . . . . . . . . . . . . . . . . . . 11
4.4.1. Discovering an Application's URLs . . . . . . . . . . 11
4.4.2. Considering URI Schemes . . . . . . . . . . . . . . . 12
4.4.3. Transport Ports . . . . . . . . . . . . . . . . . . . 13
4.5. Using HTTP Methods . . . . . . . . . . . . . . . . . . . 13
4.5.1. GET . . . . . . . . . . . . . . . . . . . . . . . . . 14
4.5.2. OPTIONS . . . . . . . . . . . . . . . . . . . . . . . 15
4.6. Using HTTP Status Codes . . . . . . . . . . . . . . . . . 16
4.6.1. Redirection . . . . . . . . . . . . . . . . . . . . . 17
4.7. Specifying HTTP Header Fields . . . . . . . . . . . . . . 18
4.8. Defining Message Payloads . . . . . . . . . . . . . . . . 19
4.9. Leveraging HTTP Caching . . . . . . . . . . . . . . . . . 19
4.9.1. Freshness . . . . . . . . . . . . . . . . . . . . . . 20
4.9.2. Stale Responses . . . . . . . . . . . . . . . . . . . 20
4.9.3. Caching and Application Semantics . . . . . . . . . . 21
4.9.4. Varying Content Based Upon the Request . . . . . . . 21
4.10. Handling Application State . . . . . . . . . . . . . . . 22
4.11. Client Authentication . . . . . . . . . . . . . . . . . . 22
4.12. Co-Existing with Web Browsing . . . . . . . . . . . . . . 22
4.13. Maintaining Application Boundaries . . . . . . . . . . . 24
4.14. Using Server Push . . . . . . . . . . . . . . . . . . . . 25
4.15. Allowing Versioning and Evolution . . . . . . . . . . . . 26
5. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 26
6. Security Considerations . . . . . . . . . . . . . . . . . . . 26
6.1. Privacy Considerations . . . . . . . . . . . . . . . . . 27
7. References . . . . . . . . . . . . . . . . . . . . . . . . . 27
7.1. Normative References . . . . . . . . . . . . . . . . . . 27
7.2. Informative References . . . . . . . . . . . . . . . . . 29
7.3. URIs . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Appendix A. Changes from RFC 3205 . . . . . . . . . . . . . . . 32
Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 32
1. Introduction 1. Introduction
HTTP [I-D.ietf-httpbis-semantics] is often used as a substrate for HTTP [I-D.ietf-httpbis-semantics] is often used as a substrate for
applications other than Web browsing; this is sometimes referred to applications other than Web browsing; this is sometimes referred to
as creating "HTTP-based APIs", "REST APIs" or just "HTTP APIs". This as creating "HTTP-based APIs", "REST APIs" or just "HTTP APIs". This
is done for a variety of reasons, including: is done for a variety of reasons, including:
o familiarity by implementers, specifiers, administrators, o familiarity by implementers, specifiers, administrators,
developers and users, developers and users,
skipping to change at page 3, line 47 skipping to change at page 2, line 50
o its ability to traverse firewalls. o its ability to traverse firewalls.
These protocols are often ad hoc; they are intended for only These protocols are often ad hoc; they are intended for only
deployment by one or a few servers, and consumption by a limited set deployment by one or a few servers, and consumption by a limited set
of clients. As a result, a body of practices and tools has arisen of clients. As a result, a body of practices and tools has arisen
around defining HTTP-based APIs that favours these conditions. around defining HTTP-based APIs that favours these conditions.
However, when such an application has multiple, separate However, when such an application has multiple, separate
implementations, is deployed on multiple uncoordinated servers, and implementations, is deployed on multiple uncoordinated servers, and
is consumed by diverse clients - as is often the case for HTTP APIs is consumed by diverse clients -- as is often the case for HTTP APIs
defined by standards efforts - tools and practices intended for defined by standards efforts -- tools and practices intended for
limited deployment can become unsuitable. limited deployment can become unsuitable.
This is largely because implementations (both client and server) will This is largely because implementations (both client and server) will
implement and evolve at different paces. As a result, such an HTTP- implement and evolve at different paces, and because deployments will
based API will need to more carefully consider how extensibility of often have different features and versions available. As a result,
the service will be handled and how different deployment requirements the designers of such an HTTP-based API will need to more carefully
will be accommodated. consider how extensibility of the service will be handled and how
different deployment requirements will be accommodated.
More generally, application protocols using HTTP face a number of More generally, an application protocol using HTTP faces a number of
design decisions, including: design decisions, including:
o Should it define a new URI scheme? Use new ports? o Should it define a new URI scheme? Use new ports?
o Should it use standard HTTP methods and status codes, or define o Should it use standard HTTP methods and status codes, or define
new ones? new ones?
o How can the maximum value be extracted from the use of HTTP? o How can the maximum value be extracted from the use of HTTP?
o How does it coexist with other uses of HTTP - especially Web o How does it coexist with other uses of HTTP -- especially Web
browsing? browsing?
o How can interoperability problems and "protocol dead ends" be o How can interoperability problems and "protocol dead ends" be
avoided? avoided?
This document contains best current practices for the specification This document contains best current practices for the specification
of such applications. Section 2 defines when it applies; Section 3 of such applications. Section 2 defines when it applies; Section 3
surveys the properties of HTTP that are important to preserve, and surveys the properties of HTTP that are important to preserve, and
Section 4 conveys best practices for the specifying them. Section 4 conveys best practices for the specifying them.
skipping to change at page 5, line 12 skipping to change at page 4, line 12
o uses the transport port 80 or 443, or o uses the transport port 80 or 443, or
o uses the URI scheme "http" or "https", or o uses the URI scheme "http" or "https", or
o uses an ALPN protocol ID [RFC7301] that generically identifies o uses an ALPN protocol ID [RFC7301] that generically identifies
HTTP (e.g., "http/1.1", "h2", "h2c"), or HTTP (e.g., "http/1.1", "h2", "h2c"), or
o updates or modifies the IANA registries defined for HTTP. o updates or modifies the IANA registries defined for HTTP.
Additionally, when a specification is using HTTP, all of the Additionally, when a specification is using HTTP, all of the
requirements of the HTTP protocol suite are in force (including but requirements of the HTTP protocol suite are in force (in particular,
not limited to [I-D.ietf-httpbis-semantics], [I-D.ietf-httpbis-semantics], but also other specifications as
[I-D.ietf-httpbis-cache], [I-D.ietf-httpbis-messaging], and appropriate).
[RFC7540]).
Note that this document is intended to apply to applications, not Note that this document is intended to apply to applications, not
generic extensions to HTTP, which follow the requirements in the generic extensions to HTTP, which follow the requirements in the
relevant specification. Furthermore, it is intended for applications relevant specification. Furthermore, it is intended for applications
defined by IETF specifications, although other standards defined by IETF specifications, although other standards
organisations are encouraged to adhere to its requirements. organisations are encouraged to adhere to its requirements.
2.1. Non-HTTP Protocols 2.1. Non-HTTP Protocols
A specification might not use HTTP according to the criteria above A specification might not use HTTP according to the criteria above
skipping to change at page 5, line 43 skipping to change at page 4, line 42
implementations won't be easily adaptable to these changes, and as implementations won't be easily adaptable to these changes, and as
the protocol diverges from HTTP, the benefit of mindshare will be the protocol diverges from HTTP, the benefit of mindshare will be
lost. lost.
Such specifications MUST NOT use HTTP's URI schemes, transport ports, Such specifications MUST NOT use HTTP's URI schemes, transport ports,
ALPN protocol IDs or IANA registries; rather, they are encouraged to ALPN protocol IDs or IANA registries; rather, they are encouraged to
establish their own. establish their own.
3. What's Important About HTTP 3. What's Important About HTTP
This section examines the facets of the protocol that are important This section examines the characteristics of the HTTP protocol that
to consider when using HTTP to define an application protocol. are important to consider when using HTTP to define an application
protocol.
3.1. Generic Semantics 3.1. Generic Semantics
Much of the value of HTTP is in its generic semantics - that is, the Much of the value of HTTP is in its generic semantics -- that is, the
protocol elements defined by HTTP are potentially applicable to every protocol elements defined by HTTP are potentially applicable to every
resource, not specific to a particular context. Application-specific resource, not specific to a particular context. Application-specific
semantics are best expressed in the payload; often in the body, but semantics are best expressed in message content and in header fields,
also in header fields. not status codes or methods -- although the latter do have generic
semantics that relate to application state.
This generic/application-specific split allows a HTTP message to be This generic/application-specific split allows a HTTP message to be
handled by software (e.g., HTTP servers, intermediaries, client handled by software (e.g., HTTP servers, intermediaries, client
implementations, and caches) without understanding the specific implementations, and caches) without understanding the specific
application. It also allows people to leverage their knowledge of application. It also allows people to leverage their knowledge of
HTTP semantics without special-casing them for a particular HTTP semantics without special-casing them for a particular
application. application.
Therefore, applications that use HTTP MUST NOT re-define, refine or Therefore, applications that use HTTP MUST NOT re-define, refine or
overlay the semantics of generic protocol elements such as methods, overlay the semantics of generic protocol elements such as methods,
status codes or existing header fields. Instead, they should focus status codes or existing header fields. Instead, they should focus
their specifications on protocol elements that are specific to that their specifications on protocol elements that are specific to that
application; namely their HTTP resources. application; namely their HTTP resources.
For example, when writing a specification, it's often tempting to When writing a specification, it's often tempting to specify exactly
specify exactly how HTTP is to be implemented, supported and used. how HTTP is to be implemented, supported and used. However, this can
easily lead to an unintended profile of HTTP's behaviour. For
However, this can easily lead to an unintended profile of HTTP's example, it's common to see specifications with language like this:
behaviour. For example, it's common to see specifications with
language like this:
A `POST` request MUST result in a `201 Created` response. A `POST` request MUST result in a `201 Created` response.
This forms an expectation in the client that the response will always This forms an expectation in the client that the response will always
be "201 Created", when in fact there are a number of reasons why the be "201 Created", when in fact there are a number of reasons why the
status code might differ in a real deployment; for example, there status code might differ in a real deployment; for example, there
might be a proxy that requires authentication, or a server-side might be a proxy that requires authentication, or a server-side
error, or a redirection. If the client does not anticipate this, the error, or a redirection. If the client does not anticipate this, the
application's deployment is brittle. application's deployment is brittle.
See Section 4.2 for more details. See Section 4.2 for more details.
3.2. Links 3.2. Links
Another common practice is assuming that the HTTP server's name space Another common practice is assuming that the HTTP server's name space
(or a portion thereof) is exclusively for the use of a single (or a portion thereof) is exclusively for the use of a single
application. This effectively overlays special, application-specific application. This effectively overlays special, application-specific
semantics onto that space, precludes other applications from using semantics onto that space, precludes other applications from using
it. it.
As explained in [RFC7320], such "squatting" on a part of the URL As explained in [RFC8820], such "squatting" on a part of the URL
space by a standard usurps the server's authority over its own space by a standard usurps the server's authority over its own
resources, can cause deployment issues, and is therefore bad practice resources, can cause deployment issues, and is therefore bad practice
in standards. in standards.
Instead of statically defining URI components like paths, it is Instead of statically defining URI components like paths, it is
RECOMMENDED that applications using HTTP define links in payloads, to RECOMMENDED that applications using HTTP define and use links, to
allow flexibility in deployment. allow flexibility in deployment.
Using runtime links in this fashion has a number of other benefits - Using runtime links in this fashion has a number of other benefits --
especially when an application is to have multiple implementations especially when an application is to have multiple implementations
and/or deployments (as is often the case for those that are and/or deployments (as is often the case for those that are
standardised). standardised).
For example, navigating with a link allows a request to be routed to For example, navigating with a link allows a request to be routed to
a different server without the overhead of a redirection, thereby a different server without the overhead of a redirection, thereby
supporting deployment across machines well. supporting deployment across machines well.
It also becomes possible to "mix and match" different applications on It also becomes possible to "mix and match" different applications on
the same server, and offers a natural mechanism for extensibility, the same server, and offers a natural mechanism for extensibility,
skipping to change at page 8, line 33 skipping to change at page 7, line 28
When specifying the use of HTTP, an application should use When specifying the use of HTTP, an application should use
[I-D.ietf-httpbis-semantics] as the primary reference; it is not [I-D.ietf-httpbis-semantics] as the primary reference; it is not
necessary to reference all of the specifications in the HTTP suite necessary to reference all of the specifications in the HTTP suite
unless there are specific reasons to do so (e.g., a particular unless there are specific reasons to do so (e.g., a particular
feature is called out). feature is called out).
Because it is a hop-by-hop protocol, a HTTP connection can be handled Because it is a hop-by-hop protocol, a HTTP connection can be handled
by implementations that are not controlled by the application; for by implementations that are not controlled by the application; for
example, proxies, CDNs, firewalls and so on. Requiring a particular example, proxies, CDNs, firewalls and so on. Requiring a particular
version of HTTP makes it difficult to use in these situations, and version of HTTP makes it difficult to use in these situations, and
harms interoperability for little reason (since HTTP's semantics are harms interoperability. Therefore, it is RECOMMENDED that
stable between protocol versions). Therefore, it is RECOMMENDED that
applications using HTTP not specify a minimum version of HTTP to be applications using HTTP not specify a minimum version of HTTP to be
used. used.
However, if an application's deployment would benefit from the use of However, if an application's deployment would benefit from the use of
a particular version of HTTP (for example, HTTP/2's multiplexing), a particular version of HTTP (for example, HTTP/2's multiplexing),
this ought be noted. this ought be noted.
Applications using HTTP MUST NOT specify a maximum version, to Applications using HTTP MUST NOT specify a maximum version, to
preserve the protocol's ability to evolve. preserve the protocol's ability to evolve.
When specifying examples of protocol interactions, applications When specifying examples of protocol interactions, applications
should document both the request and response messages, with full should document both the request and response messages, with complete
headers, preferably in HTTP/1.1 format. For example: header sections, preferably in HTTP/1.1 format. For example:
GET /thing HTTP/1.1 GET /thing HTTP/1.1
Host: example.com Host: example.com
Accept: application/things+json Accept: application/things+json
User-Agent: Foo/1.0 User-Agent: Foo/1.0
HTTP/1.1 200 OK HTTP/1.1 200 OK
Content-Type: application/things+json Content-Type: application/things+json
Content-Length: 500 Content-Length: 500
Server: Bar/2.2 Server: Bar/2.2
[payload here] [payload here]
4.2. Specifying Server Behaviour 4.2. Specifying Server Behaviour
The most effective way to specify an application's server-side HTTP The most effective way to specify an application's server-side HTTP
skipping to change at page 9, line 38 skipping to change at page 8, line 32
[RFC8288]. [RFC8288].
By composing these protocol elements, an application can define a set By composing these protocol elements, an application can define a set
of resources, identified by link relations, that implement specified of resources, identified by link relations, that implement specified
behaviours, including: behaviours, including:
o retrieval of their state using GET, in one or more formats o retrieval of their state using GET, in one or more formats
identified by media type; identified by media type;
o resource creation or update using POST or PUT, with an o resource creation or update using POST or PUT, with an
appropriately identified request body format; appropriately identified request content format;
o data processing using POST and identified request and response o data processing using POST and identified request and response
body format(s); and content format(s); and
o Resource deletion using DELETE. o Resource deletion using DELETE.
For example, an application might specify: For example, an application might specify:
Resources linked to with the "example-widget" link relation type are Resources linked to with the "example-widget" link relation type are
Widgets. The state of a Widget can be fetched in the Widgets. The state of a Widget can be fetched in the
"application/example-widget+json" format, and can be updated by PUT "application/example-widget+json" format, and can be updated by PUT
to the same link. Widget resources can be deleted. to the same link. Widget resources can be deleted.
skipping to change at page 10, line 44 skipping to change at page 9, line 44
problems. In particular: problems. In particular:
o Redirect handling - Applications need to specify how redirects are o Redirect handling - Applications need to specify how redirects are
expected to be handled; see Section 4.6.1. expected to be handled; see Section 4.6.1.
o Cookies - Applications using HTTP should explicitly reference the o Cookies - Applications using HTTP should explicitly reference the
Cookie specification [I-D.ietf-httpbis-rfc6265bis] if they are Cookie specification [I-D.ietf-httpbis-rfc6265bis] if they are
required. required.
o Certificates - Applications using HTTP should specify that TLS o Certificates - Applications using HTTP should specify that TLS
certificates are to be checked according to [RFC2818] when HTTPS certificates are to be checked according to
is used. [I-D.ietf-httpbis-semantics], Section 4.3.4 when HTTPS is used.
Applications using HTTP MUST NOT require HTTP features that are Applications using HTTP MUST NOT require HTTP features that are
usually negotiated to be supported by clients. For example, usually negotiated to be supported by clients. For example,
requiring that clients support responses with a certain content- requiring that clients support responses with a certain content-
coding ([I-D.ietf-httpbis-semantics], Section 6.2.2) instead of coding ([I-D.ietf-httpbis-semantics], Section 8.4.1) instead of
negotiating for it ([I-D.ietf-httpbis-semantics], Section 8.4.4) negotiating for it ([I-D.ietf-httpbis-semantics], Section 12.5.3)
means that otherwise conformant clients cannot interoperate with the means that otherwise conformant clients cannot interoperate with the
application. Applications can encourage the implementation of such application. Applications can encourage the implementation of such
features, though. features, though.
4.4. Specifying URLs 4.4. Specifying URLs
In HTTP, the server resources that clients interact with are In HTTP, the server resources that clients interact with are
identified with URLs [RFC3986]. As [RFC7320] explains, parts of the identified with URLs [RFC3986]. As [RFC8820] explains, parts of the
URL are designed to be under the control of the owner (also known as URL are designed to be under the control of the owner (also known as
the "authority") of that server, to give them the flexibility in the "authority") of that server, to give them the flexibility in
deployment. deployment.
This means that in most cases, specifications for applications that This means that in most cases, specifications for applications that
use HTTP won't contain its URLs; while it is common practice for a use HTTP won't contain its URLs; while it is common practice for a
specification of a single-deployment API to specify the path prefix specification of a single-deployment API to specify the path prefix
"/app/v1" (for example), doing so in an IETF specification is "/app/v1" (for example), doing so in an IETF specification is
inappropriate. inappropriate.
skipping to change at page 11, line 40 skipping to change at page 10, line 40
about that particular deployment, potentially including links to about that particular deployment, potentially including links to
other relevant resources. Doing so assures that the deployment is as other relevant resources. Doing so assures that the deployment is as
flexible as possible (potentially spanning multiple servers), allows flexible as possible (potentially spanning multiple servers), allows
evolution, and also gives the application the opportunity to tailor evolution, and also gives the application the opportunity to tailor
the 'discovery document' to the client. the 'discovery document' to the client.
There are a few common patterns for discovering that initial URL. There are a few common patterns for discovering that initial URL.
The most straightforward mechanism for URL discovery is to configure The most straightforward mechanism for URL discovery is to configure
the client with (or otherwise convey to it) a full URL. This might the client with (or otherwise convey to it) a full URL. This might
be done in a configuration document, in DNS or mDNS, or through be done in a configuration document, or through another discovery
another discovery mechanism. mechanism.
However, if the client only knows the server's hostname and the However, if the client only knows the server's hostname and the
identity of the application, there needs to be some way to derive the identity of the application, there needs to be some way to derive the
initial URL from that information. initial URL from that information.
Applications MUST NOT define a fixed prefix for its URL paths; for An application cannot define a fixed prefix for its URL paths; see
reasons explained in [RFC7320], this is bad practice. [RFC8820]. Instead, a specification for such an application can use
one of the following strategies:
Instead, a specification for such an application can use one of the
following strategies:
o Register a Well-Known URI [I-D.nottingham-rfc5785bis] as an entry o Register a Well-Known URI [RFC8615] as an entry point for that
point for that application. This provides a fixed path on every application. This provides a fixed path on every potential server
potential server that will not collide with other applications. that will not collide with other applications.
o Enable the server authority to convey a URL Template [RFC6570] or o Enable the server authority to convey a URL Template [RFC6570] or
similar mechanism for generating a URL for an entry point. For similar mechanism for generating a URL for an entry point. For
example, this might be done in a DNS RR, a configuration document, example, this might be done in a configuration document or other
or other artefact. artefact.
Once the discovery document is located, it can be fetched, cached for Once the discovery document is located, it can be fetched, cached for
later reuse (if allowed by its metadata), and used to locate other later reuse (if allowed by its metadata), and used to locate other
resources that are relevant to the application, using full URIs or resources that are relevant to the application, using full URIs or
URL Templates. URL Templates.
In some cases, an application may not wish to use such a discovery In some cases, an application may not wish to use such a discovery
document; for example, when communication is very brief, or when the document; for example, when communication is very brief, or when the
latency concerns of doing so precludes the use of a discovery latency concerns of doing so precludes the use of a discovery
document. These situations can be addressed by placing all of the document. These situations can be addressed by placing all of the
skipping to change at page 12, line 49 skipping to change at page 11, line 49
proprietary approaches), support for these mechanisms is not proprietary approaches), support for these mechanisms is not
shared by all browsers, and their capabilities vary. shared by all browsers, and their capabilities vary.
o Existing non-browser clients, intermediaries, servers and o Existing non-browser clients, intermediaries, servers and
associated software will not recognise the new scheme. For associated software will not recognise the new scheme. For
example, a client library might fail to dispatch the request; a example, a client library might fail to dispatch the request; a
cache might refuse to store the response, and a proxy might fail cache might refuse to store the response, and a proxy might fail
to forward the request. to forward the request.
o Because URLs occur in HTTP artefacts commonly, often being o Because URLs occur in HTTP artefacts commonly, often being
generated automatically (e.g., in the "Location" response header), generated automatically (e.g., in the "Location" response header
it can be difficult to assure that the new scheme is used field), it can be difficult to assure that the new scheme is used
consistently. consistently.
o The resources identified by the new scheme will still be available o The resources identified by the new scheme will still be available
using "http" and/or "https" URLs. Those URLs can "leak" into use, using "http" and/or "https" URLs. Those URLs can "leak" into use,
which can present security and operability issues. For example, which can present security and operability issues. For example,
using a new scheme to assure that requests don't get sent to a using a new scheme to assure that requests don't get sent to a
"normal" Web site is likely to fail. "normal" Web site is likely to fail.
o Features that rely upon the URL's origin [RFC6454], such as the o Features that rely upon the URL's origin [RFC6454], such as the
Web's same-origin policy, will be impacted by a change of scheme. Web's same-origin policy, will be impacted by a change of scheme.
skipping to change at page 13, line 37 skipping to change at page 12, line 37
4.4.3. Transport Ports 4.4.3. Transport Ports
Applications can use the applicable default port (80 for HTTP, 443 Applications can use the applicable default port (80 for HTTP, 443
for HTTPS), or they can be deployed upon other ports. This decision for HTTPS), or they can be deployed upon other ports. This decision
can be made at deployment time, or might be encouraged by the can be made at deployment time, or might be encouraged by the
application's specification (e.g., by registering a port for that application's specification (e.g., by registering a port for that
application). application).
If a non-default port is used, it needs to be reflected in the If a non-default port is used, it needs to be reflected in the
authority of all URLs for that resource; the only mechanism for authority of all URLs for that resource; the only mechanism for
changing a default port is changing the scheme (see Section 4.4.2). changing a default port is changing the URI scheme (see
Section 4.4.2).
Using a port other than the default has privacy implications (i.e., Using a port other than the default has privacy implications (i.e.,
the protocol can now be distinguished from other traffic), as well as the protocol can now be distinguished from other traffic), as well as
operability concerns (as some networks might block or otherwise operability concerns (as some networks might block or otherwise
interfere with it). Privacy implications should be documented in interfere with it). Privacy implications should be documented in
Security Considerations. Security Considerations.
See [RFC7605] for further guidance. See [RFC7605] for further guidance.
4.5. Using HTTP Methods 4.5. Using HTTP Methods
skipping to change at page 14, line 38 skipping to change at page 13, line 38
expensive process. expensive process.
In some cases, however, GET might be unwieldy for expressing queries, In some cases, however, GET might be unwieldy for expressing queries,
because of the limited syntax of the URI; in particular, if binary because of the limited syntax of the URI; in particular, if binary
data forms part of the query terms, it needs to be encoded to conform data forms part of the query terms, it needs to be encoded to conform
to URI syntax. to URI syntax.
While this is not an issue for short queries, it can become one for While this is not an issue for short queries, it can become one for
larger query terms, or ones which need to sustain a high rate of larger query terms, or ones which need to sustain a high rate of
requests. Additionally, some HTTP implementations limit the size of requests. Additionally, some HTTP implementations limit the size of
URLs they support - although modern HTTP software has much more URLs they support -- although modern HTTP software has much more
generous limits than previously (typically, considerably more than generous limits than previously (typically, considerably more than
8000 octets, as required by [I-D.ietf-httpbis-semantics]. 8000 octets, as required by [I-D.ietf-httpbis-semantics].
In these cases, an application using HTTP might consider using POST In these cases, an application using HTTP might consider using POST
to express queries in the request body; doing so avoids encoding to express queries in the request's content; doing so avoids encoding
overhead and URL length limits in implementations. However, in doing overhead and URL length limits in implementations. However, in doing
so it should be noted that the benefits of GET such as caching and so it should be noted that the benefits of GET such as caching and
linking to query results are lost. Therefore, applications using linking to query results are lost. Therefore, applications using
HTTP that feel a need to allow POST queries ought consider allowing HTTP that feel a need to allow POST queries ought consider allowing
both methods. both methods.
Applications should not change their state or have other side effects Applications should not change their state or have other side effects
that might be significant to the client, since implementations can that might be significant to the client, since implementations can
and do retry HTTP GET requests that fail. Note that this does not and do retry HTTP GET requests that fail. Note that this does not
include logging and similar functions; see include logging and similar functions; see
[I-D.ietf-httpbis-semantics], Section 7.2.1. [I-D.ietf-httpbis-semantics], Section 9.2.1.
Finally, note that while HTTP allows GET requests to have a body Finally, note that while HTTP allows GET requests to have content
syntactically, this is done only to allow parsers to be generic; as syntactically, this is done only to allow parsers to be generic; as
per [I-D.ietf-httpbis-semantics], Section 7.3.1, a body on a GET has per [I-D.ietf-httpbis-semantics], Section 9.3.1, content on a GET has
no meaning, and will be either ignored or rejected by generic HTTP no meaning, and will be either ignored or rejected by generic HTTP
software. software.
4.5.2. OPTIONS 4.5.2. OPTIONS
The OPTIONS method was defined for metadata retrieval, and is used The OPTIONS method was defined for metadata retrieval, and is used
both by WebDAV [RFC4918] and CORS [FETCH]. Because HTTP-based APIs both by WebDAV [RFC4918] and CORS [FETCH]. Because HTTP-based APIs
often need to retrieve metadata about resources, it is often often need to retrieve metadata about resources, it is often
considered for their use. considered for their use.
skipping to change at page 15, line 42 skipping to change at page 14, line 42
separate request increases the number of requests needed to separate request increases the number of requests needed to
interact with the application. interact with the application.
o Implementation support for OPTIONS is not universal; some servers o Implementation support for OPTIONS is not universal; some servers
do not expose the ability to respond to OPTIONS requests without do not expose the ability to respond to OPTIONS requests without
significant effort. significant effort.
Instead of OPTIONS, one of these alternative approaches might be more Instead of OPTIONS, one of these alternative approaches might be more
appropriate: appropriate:
o For server-wide metadata, create a well-known URI o For server-wide metadata, create a well-known URI [RFC8615], or
[I-D.nottingham-rfc5785bis], or using an already existing one if using an already existing one if it's appropriate (e.g., HostMeta
it's appropriate (e.g., HostMeta [RFC6415]). [RFC6415]).
o For metadata about a specific resource, create a separate resource o For metadata about a specific resource, create a separate resource
and link to it using a Link response header or a link serialised and link to it using a Link response header field or a link
into the representation's body. See [RFC8288]. Note that the serialised into the response's content. See [RFC8288]. Note that
Link header is available on HEAD responses, which is useful if the the Link header field is available on HEAD responses, which is
client wants to discover a resource's capabilities before they useful if the client wants to discover a resource's capabilities
interact with it. before they interact with it.
4.6. Using HTTP Status Codes 4.6. Using HTTP Status Codes
HTTP status codes convey semantics both for the benefit of generic HTTP status codes convey semantics both for the benefit of generic
HTTP components - such as caches, intermediaries, and clients - and HTTP components -- such as caches, intermediaries, and clients -- and
applications themselves. However, applications can encounter a applications themselves. However, applications can encounter a
number of pitfalls in their use. number of pitfalls in their use.
First, status codes are often generated by intermediaries, as well as First, status codes are often generated by components other the the
server and client implementations. This can happen, for example, application itself. This can happen, for example, when network
when network errors are encountered, a captive portal is present, errors are encountered, a captive portal, proxy or Content Delivery
when an implementation is overloaded, or it thinks it is under Network is present, when a server is overloaded, or it thinks it is
attack. As a result, if an application assigns specific semantics to under attack. They can even be generated by generic client software
one of these status codes, a client can be misled about its state, when certain error conditions are encountered. As a result, if an
because the status code was generated by a generic component, not the application assigns specific semantics to one of these status codes,
application itself. a client can be misled about its state, because the status code was
generated by a generic component, not the application itself.
Furthermore, mapping application errors to individual HTTP status Furthermore, mapping application errors to individual HTTP status
codes one-to-one often leads to a situation where the finite space of codes one-to-one often leads to a situation where the finite space of
applicable HTTP status codes is exhausted. This, in turn, leads to a applicable HTTP status codes is exhausted. This, in turn, leads to a
number of bad practices - including minting new, application-specific number of bad practices -- including minting new, application-
status codes, or using existing status codes even though the link specific status codes, or using existing status codes even though the
between their semantics and the application's is tenuous at best. link between their semantics and the application's is tenuous at
best.
Instead, applications using HTTP should define their errors to use Instead, applications using HTTP should define their errors to use
the most applicable status code, making generous use of the general the most applicable status code, making generous use of the general
status codes (200, 400 and 500) when in doubt. Importantly, they status codes (200, 400 and 500) when in doubt. Importantly, they
should not specify a one-to-one relationship between status codes and should not specify a one-to-one relationship between status codes and
application errors, thereby avoiding the exhaustion issue outlined application errors, thereby avoiding the exhaustion issue outlined
above. above.
To distinguish between multiple error conditions that are mapped to To distinguish between multiple error conditions that are mapped to
the same status code, and to avoid the misattribution issue outlined the same status code, and to avoid the misattribution issue outlined
above, applications using HTTP should convey finer-grained error above, applications using HTTP should convey finer-grained error
information in the response's message body and/or header fields. information in the response's message content and/or header fields.
[RFC7807] provides one way to do so. [RFC7807] provides one way to do so.
Because the set of registered HTTP status codes can expand, Because the set of registered HTTP status codes can expand,
applications using HTTP should explicitly point out that clients applications using HTTP should explicitly point out that clients
ought to be able to handle all applicable status codes gracefully ought to be able to handle all applicable status codes gracefully
(i.e., falling back to the generic "n00" semantics of a given status (i.e., falling back to the generic "n00" semantics of a given status
code; e.g., "499" can be safely handled as "400" by clients that code; e.g., "499" can be safely handled as "400" by clients that
don't recognise it). This is preferable to creating a "laundry list" don't recognise it). This is preferable to creating a "laundry list"
of potential status codes, since such a list won't be complete in the of potential status codes, since such a list won't be complete in the
foreseeable future. foreseeable future.
skipping to change at page 17, line 22 skipping to change at page 16, line 26
[I-D.ietf-httpbis-semantics]) to be potentially applicable to all [I-D.ietf-httpbis-semantics]) to be potentially applicable to all
resources, not just to those of one application. resources, not just to those of one application.
When authors believe that a new status code is required, they are When authors believe that a new status code is required, they are
encouraged to engage with the HTTP community early, and document encouraged to engage with the HTTP community early, and document
their proposal as a separate HTTP extension, rather than as part of their proposal as a separate HTTP extension, rather than as part of
an application's specification. an application's specification.
4.6.1. Redirection 4.6.1. Redirection
The 3xx series of status codes specified in Section 9.4 The 3xx series of status codes specified in
[I-D.ietf-httpbis-semantics] direct the user agent to another [I-D.ietf-httpbis-semantics], Section 15.4 direct the user agent to
resource to satisfy the request. The most common of these are 301, another resource to satisfy the request. The most common of these
302, 307 and 308, all of which use the Location response header field are 301, 302, 307 and 308, all of which use the Location response
to indicate where the client should send the request to. header field to indicate where the client should send the request to.
There are two ways that this group of status codes differ: There are two ways that this group of status codes differ:
o Whether they are permanent or temporary. Permanent redirects can o Whether they are permanent or temporary. Permanent redirects can
be used to update links stored in the client (e.g., bookmarks), be used to update links stored in the client (e.g., bookmarks),
whereas temporary ones can not. Note that this has no effect on whereas temporary ones can not. Note that this has no effect on
HTTP caching; it is completely separate. HTTP caching; it is completely separate.
o Whether they allow the redirected request to change the request o Whether they allow the redirected request to change the request
method from POST to GET. Web browsers generally do change POST to method from POST to GET. Web browsers generally do change POST to
GET for 301 and 302; therefore, 308 and 307 were created to allow GET for 301 and 302; therefore, 308 and 307 were created to allow
redirection without changing the method. redirection without changing the method.
This table summarises their relationships: This table summarises their relationships:
+-------------------------------------------+-----------+-----------+ +-------------------------------------------+-----------+-----------+
| | Permanent | Temporary | | | Permanent | Temporary |
+-------------------------------------------+-----------+-----------+ +-------------------------------------------+-----------+-----------+
| Allows changing the request method from | 301 | 302 | | Allows changing the request method from | 301 | 302 |
| POST to GET | | | | POST to GET | | |
| | | |
| Does not allow changing the request | 308 | 307 | | Does not allow changing the request | 308 | 307 |
| method | | | | method | | |
+-------------------------------------------+-----------+-----------+ +-------------------------------------------+-----------+-----------+
As noted in [I-D.ietf-httpbis-semantics], a user agent is allowed to As noted in [I-D.ietf-httpbis-semantics], a user agent is allowed to
automatically follow a 3xx redirect that has a Location response automatically follow a 3xx redirect that has a Location response
header field, even if they don't understand the semantics of the header field, even if they don't understand the semantics of the
specific status code. However, they aren't required to do so; specific status code. However, they aren't required to do so;
therefore, if an application using HTTP desires redirects to be therefore, if an application using HTTP desires redirects to be
automatically followed, it needs to explicitly specify the automatically followed, it needs to explicitly specify the
circumstances when this is required. circumstances when this is required.
Applications using HTTP are encouraged to specify that 301 and 302 Applications using HTTP are encouraged to specify that 301 and 302
responses change the subsequent request method from POST (but no responses change the subsequent request method from POST (but no
other method) to GET, to be compatible with browsers. other method) to GET, to be compatible with browsers. Generally,
when a redirected request is made, its header fields are copied from
Generally, when a redirected request is made, its header fields are the original request's. However, they can be modified by various
copied from the original request's. However, they can be modified by mechanisms; e.g., sent Authorization ([I-D.ietf-httpbis-semantics])
various mechanisms; e.g., sent Authorization and Cookie ([I-D.ietf-httpbis-rfc6265bis]) header fields will change
([I-D.ietf-httpbis-semantics]) and Cookie if the origin (and sometimes path) of the request changes. An
([I-D.ietf-httpbis-rfc6265bis]) headers will change if the origin application using HTTP should specify if any request header fields
(and sometimes path) of the request changes. An application using that it defines need to be modified or removed upon a redirect;
HTTP should specify if any request headers that it defines need to be however, this behaviour cannot be relied upon, since a generic client
modified or removed upon a redirect; however, this behaviour cannot (like a browser) will be unaware of such requirements.
be relied upon, since a generic client (like a browser) will be
unaware of such requirements.
4.7. Specifying HTTP Header Fields 4.7. Specifying HTTP Header Fields
Applications often define new HTTP header fields. Typically, using Applications often define new HTTP header fields. Typically, using
HTTP header fields is appropriate in a few different situations: HTTP header fields is appropriate in a few different situations:
o Their content is useful to intermediaries (who often wish to avoid o The field is useful to intermediaries (who often wish to avoid
parsing the body), and/or parsing message content), and/or
o Their content is useful to generic HTTP software (e.g., clients, o The field is useful to generic HTTP software (e.g., clients,
servers), and/or servers), and/or
o It is not possible to include their content in the message body o It is not possible to include their values in the message content
(usually because a format does not allow it). (usually because a format does not allow it).
When the conditions above are not met, it is usually better to convey When the conditions above are not met, it is usually better to convey
application-specific information in other places; e.g., the message application-specific information in other places; e.g., the message
body or the URL query string. content or the URL query string.
New header fields MUST be registered, as per New header fields MUST be registered, as per
[I-D.ietf-httpbis-semantics]. [I-D.ietf-httpbis-semantics].
See [I-D.ietf-httpbis-semantics], Section 4.1.3 for guidelines to See [I-D.ietf-httpbis-semantics], Section 16.3.2 for guidelines to
consider when minting new header fields. consider when minting new header fields.
[I-D.ietf-httpbis-header-structure] provides a common structure for [I-D.ietf-httpbis-header-structure] provides a common structure for
new header fields, and avoids many issues in their parsing and new header fields, and avoids many issues in their parsing and
handling; it is RECOMMENDED that new header fields use it. handling; it is RECOMMENDED that new header fields use it.
It is RECOMMENDED that header field names be short (even when HTTP/2 It is RECOMMENDED that header field names be short (even when field
header compression is in effect, there is an overhead) but compression is used, there is an overhead) but appropriately
appropriately specific. In particular, if a header field is specific specific. In particular, if a header field is specific to an
to an application, an identifier for that application can form a application, an identifier for that application can form a prefix to
prefix to the header field name, separated by a "-". the header field name, separated by a "-".
For example, if the "example" application needs to create three For example, if the "example" application needs to create three
headers, they might be called "example-foo", "example-bar" and headers, they might be called "example-foo", "example-bar" and
"example-baz". Note that the primary motivation here is to avoid "example-baz". Note that the primary motivation here is to avoid
consuming more generic header names, not to reserve a portion of the consuming more generic field names, not to reserve a portion of the
namespace for the application; see [RFC6648] for related namespace for the application; see [RFC6648] for related
considerations. considerations.
The semantics of existing HTTP header fields MUST NOT be re-defined The semantics of existing HTTP header fields MUST NOT be re-defined
without updating their registration or defining an extension to them without updating their registration or defining an extension to them
(if allowed). For example, an application using HTTP cannot specify (if allowed). For example, an application using HTTP cannot specify
that the "Location" header has a special meaning in a certain that the "Location" header field has a special meaning in a certain
context. context.
See Section 4.9 for the interaction between headers and HTTP caching; See Section 4.9 for the interaction between headers and HTTP caching;
in particular, request headers that are used to "select" a response in particular, request header fields that are used to "select" a
have impact there, and need to be carefully considered. response have impact there, and need to be carefully considered.
See Section 4.10 for considerations regarding header fields that See Section 4.10 for considerations regarding header fields that
carry application state (e.g., Cookie). carry application state (e.g., Cookie).
4.8. Defining Message Payloads 4.8. Defining Message Payloads
There are many potential formats for payloads; for example, JSON There are many potential formats for payloads; for example, JSON
[RFC8259], XML [XML], and CBOR [RFC7049]. Best practices for their [RFC8259], XML [XML], and CBOR [RFC7049]. Best practices for their
use are out of scope for this document. use are out of scope for this document.
skipping to change at page 20, line 13 skipping to change at page 19, line 22
software. software.
Even when an application using HTTP isn't designed to take advantage Even when an application using HTTP isn't designed to take advantage
of caching, it needs to consider how caches will handle its of caching, it needs to consider how caches will handle its
responses, to preserve correct behaviour when one is interposed responses, to preserve correct behaviour when one is interposed
(whether in the network, server, client, or intervening (whether in the network, server, client, or intervening
infrastructure). infrastructure).
4.9.1. Freshness 4.9.1. Freshness
Assigning even a short freshness lifetime (Section 4.2 of Assigning even a short freshness lifetime ([I-D.ietf-httpbis-cache],
[I-D.ietf-httpbis-cache]) - e.g., 5 seconds - allows a response to be Section 4.2) -- e.g., 5 seconds -- allows a response to be reused to
reused to satisfy multiple clients, and/or a single client making the satisfy multiple clients, and/or a single client making the same
same request repeatedly. In general, if it is safe to reuse request repeatedly. In general, if it is safe to reuse something,
something, consider assigning a freshness lifetime. consider assigning a freshness lifetime.
The most common method for specifying freshness is the max-age The most common method for specifying freshness is the max-age
response directive (Section 5.2.2.8 of [I-D.ietf-httpbis-cache]). response directive ([I-D.ietf-httpbis-cache], Section 5.2.2.9). The
The Expires header (Section 5.3 of [I-D.ietf-httpbis-cache]) can also Expires header field ([I-D.ietf-httpbis-cache], Section 5.3) can also
be used, but it is not necessary; all modern cache implementations be used, but it is not necessary; all modern cache implementations
support Cache-Control, and specifying freshness as a delta is usually support Cache-Control, and specifying freshness as a delta is usually
more convenient and less error-prone. more convenient and less error-prone.
In some situations, responses without explicit cache freshness In some situations, responses without explicit cache freshness
directives will be stored and served using a heuristic freshness directives will be stored and served using a heuristic freshness
lifetime; see [I-D.ietf-httpbis-cache], Section 4.2.2. As the lifetime; see [I-D.ietf-httpbis-cache], Section 4.2.2. As the
heuristic is not under control of the application, it is generally heuristic is not under control of the application, it is generally
preferable to set an explicit freshness lifetime, or make the preferable to set an explicit freshness lifetime, or make the
response explicitly uncacheable. response explicitly uncacheable.
skipping to change at page 21, line 18 skipping to change at page 20, line 30
content. content.
Stale responses can be refreshed by assigning a validator, saving Stale responses can be refreshed by assigning a validator, saving
both transfer bandwidth and latency for large responses; see both transfer bandwidth and latency for large responses; see
[I-D.ietf-httpbis-semantics]. [I-D.ietf-httpbis-semantics].
4.9.3. Caching and Application Semantics 4.9.3. Caching and Application Semantics
When an application has a need to express a lifetime that's separate When an application has a need to express a lifetime that's separate
from the freshness lifetime, this should be conveyed separately, from the freshness lifetime, this should be conveyed separately,
either in the response's body or in a separate header field. When either in the response's content or in a separate header field. When
this happens, the relationship between HTTP caching and that lifetime this happens, the relationship between HTTP caching and that lifetime
need to be carefully considered, since the response will be used as need to be carefully considered, since the response will be used as
long as it is considered fresh. long as it is considered fresh.
In particular, application authors need to consider how responses In particular, application authors need to consider how responses
that are not freshly obtained from the origin server should be that are not freshly obtained from the origin server should be
handled; if they have a concept like a validity period, this will handled; if they have a concept like a validity period, this will
need to be calculated considering the age of the response (see need to be calculated considering the age of the response (see
Section 4.2.3 of [I-D.ietf-httpbis-cache]). [I-D.ietf-httpbis-cache], Section 4.2.3).
One way to address this is to explicitly specify that all responses One way to address this is to explicitly specify that all responses
be fresh upon use. be fresh upon use.
4.9.4. Varying Content Based Upon the Request 4.9.4. Varying Content Based Upon the Request
If an application uses a request header field to change the If an application uses a request header field to change the
response's headers or body, authors should point out that this has response's headers or content, authors should point out that this has
implications for caching; in general, such resources need to either implications for caching; in general, such resources need to either
make their responses uncacheable (e.g., with the "no-store" cache- make their responses uncacheable (e.g., with the "no-store" cache-
control directive defined in [I-D.ietf-httpbis-cache], control directive defined in [I-D.ietf-httpbis-cache],
Section 5.2.2.3) or send the Vary response header Section 5.2.2.3) or send the Vary response header field
([I-D.ietf-httpbis-semantics], Section 10.1.4) on all responses from ([I-D.ietf-httpbis-semantics], Section 12.5.5) on all responses from
that resource (including the "default" response). that resource (including the "default" response).
For example, this response: For example, this response:
HTTP/1.1 200 OK HTTP/1.1 200 OK
Content-Type: application/example+xml Content-Type: application/example+xml
Cache-Control: max-age=60 Cache-Control: max-age=60
ETag: "sa0f8wf20fs0f" ETag: "sa0f8wf20fs0f"
Vary: Accept-Encoding Vary: Accept-Encoding
skipping to change at page 23, line 29 skipping to change at page 22, line 41
This is only a small sample of the kinds of issues that applications This is only a small sample of the kinds of issues that applications
using HTTP must consider. Generally, the best approach is to using HTTP must consider. Generally, the best approach is to
consider the application actually as a Web application, and to follow consider the application actually as a Web application, and to follow
best practices for their secure development. best practices for their secure development.
A complete enumeration of such practices is out of scope for this A complete enumeration of such practices is out of scope for this
document, but some considerations include: document, but some considerations include:
o Using an application-specific media type in the Content-Type o Using an application-specific media type in the Content-Type
header, and requiring clients to fail if it is not used. header field, and requiring clients to fail if it is not used.
o Using X-Content-Type-Options: nosniff [FETCH] to assure that o Using X-Content-Type-Options: nosniff [FETCH] to assure that
content under attacker control can't be coaxed into a form that is content under attacker control can't be coaxed into a form that is
interpreted as active content by a Web browser. interpreted as active content by a Web browser.
o Using Content-Security-Policy [CSP] to constrain the capabilities o Using Content-Security-Policy [CSP] to constrain the capabilities
of active content (such as HTML [HTML]), thereby mitigating Cross- of active content (such as HTML [HTML]), thereby mitigating Cross-
Site Scripting attacks. Site Scripting attacks.
o Using Referrer-Policy [REFERRER-POLICY] to prevent sensitive data o Using Referrer-Policy [REFERRER-POLICY] to prevent sensitive data
in URLs from being leaked in the Referer request header. in URLs from being leaked in the Referer request header field.
o Using the 'HttpOnly' flag on Cookies to assure that cookies are o Using the 'HttpOnly' flag on Cookies to assure that cookies are
not exposed to browser scripting languages not exposed to browser scripting languages
[I-D.ietf-httpbis-rfc6265bis]. [I-D.ietf-httpbis-rfc6265bis].
o Avoiding use of compression on any sensitive information (e.g., o Avoiding use of compression on any sensitive information (e.g.,
authentication tokens, passwords), as the scripting environment authentication tokens, passwords), as the scripting environment
offered by Web browsers allows an attacker to repeatedly probe the offered by Web browsers allows an attacker to repeatedly probe the
compression space; if the attacker has access to the path of the compression space; if the attacker has access to the path of the
communication, they can use this capability to recover that communication, they can use this capability to recover that
skipping to change at page 24, line 45 skipping to change at page 24, line 9
For example, if Cookies [I-D.ietf-httpbis-rfc6265bis] are used to For example, if Cookies [I-D.ietf-httpbis-rfc6265bis] are used to
carry application state, they will be sent with all requests to the carry application state, they will be sent with all requests to the
origin by default, unless scoped by path, and the application might origin by default, unless scoped by path, and the application might
receive cookies from other applications on the origin. This can lead receive cookies from other applications on the origin. This can lead
to security issues, as well as collision in cookie names. to security issues, as well as collision in cookie names.
One solution to these issues is to require a dedicated hostname for One solution to these issues is to require a dedicated hostname for
the application, so that it has a unique origin. However, it is the application, so that it has a unique origin. However, it is
often desirable to allow multiple applications to be deployed on a often desirable to allow multiple applications to be deployed on a
single hostname; doing so provides the most deployment flexibility single hostname; doing so provides the most deployment flexibility
and enables them to be "mixed" together (See [RFC7320] for details). and enables them to be "mixed" together (See [RFC8820] for details).
Therefore, applications using HTTP should strive to allow multiple Therefore, applications using HTTP should strive to allow multiple
applications on an origin. applications on an origin.
To enable this, when specifying the use of Cookies, HTTP To enable this, when specifying the use of Cookies, HTTP
authentication realms [I-D.ietf-httpbis-semantics], or other origin- authentication realms [I-D.ietf-httpbis-semantics], or other origin-
wide HTTP mechanisms, applications using HTTP should not mandate the wide HTTP mechanisms, applications using HTTP should not mandate the
use of a particular name, but instead let deployments configure them. use of a particular name, but instead let deployments configure them.
Consideration should be given to scoping them to part of the origin, Consideration should be given to scoping them to part of the origin,
using their specified mechanisms for doing so. using their specified mechanisms for doing so.
Modern Web browsers constrain the ability of content from one origin Modern Web browsers constrain the ability of content from one origin
to access resources from another, to avoid leaking private to access resources from another, to avoid leaking private
information. As a result, applications that wish to expose cross- information. As a result, applications that wish to expose cross-
origin data to browsers will need to implement the CORS protocol; see origin data to browsers will need to implement the CORS protocol; see
[FETCH]. [FETCH].
4.14. Using Server Push 4.14. Using Server Push
skipping to change at page 26, line 20 skipping to change at page 25, line 33
In HTTP, backwards-incompatible changes are possible using a number In HTTP, backwards-incompatible changes are possible using a number
of mechanisms: of mechanisms:
o Using a distinct link relation type [RFC8288] to identify a URL o Using a distinct link relation type [RFC8288] to identify a URL
for a resource that implements the new functionality. for a resource that implements the new functionality.
o Using a distinct media type [RFC6838] to identify formats that o Using a distinct media type [RFC6838] to identify formats that
enable the new functionality. enable the new functionality.
o Using a distinct HTTP header field to implement new functionality o Using a distinct HTTP header field to implement new functionality
outside the message body. outside the message content.
5. IANA Considerations 5. IANA Considerations
This document has no requirements for IANA. This document has no requirements for IANA.
6. Security Considerations 6. Security Considerations
Section 4.10 discusses the impact of using stateful mechanisms in the Section 4.10 discusses the impact of using stateful mechanisms in the
protocol as ambient authority, and suggests a mitigation. protocol as ambient authority, and suggests a mitigation.
skipping to change at page 26, line 45 skipping to change at page 26, line 9
Section 4.12 highlights the implications of Web browsers' Section 4.12 highlights the implications of Web browsers'
capabilities on applications that use HTTP. capabilities on applications that use HTTP.
Section 4.13 discusses the issues that arise when applications are Section 4.13 discusses the issues that arise when applications are
deployed on the same origin as Web sites (and other applications). deployed on the same origin as Web sites (and other applications).
Section 4.14 highlights risks of using HTTP/2 server push in a manner Section 4.14 highlights risks of using HTTP/2 server push in a manner
other than specified. other than specified.
Applications that use HTTP in a manner that involves modification of Applications that use HTTP in a manner that involves modification of
implementations - for example, requiring support for a new URI implementations -- for example, requiring support for a new URI
scheme, or a non-standard method - risk having those implementations scheme, or a non-standard method -- risk having those implementations
"fork" from their parent HTTP implementations, with the possible "fork" from their parent HTTP implementations, with the possible
result that they do not benefit from patches and other security result that they do not benefit from patches and other security
improvements incorporated upstream. improvements incorporated upstream.
6.1. Privacy Considerations 6.1. Privacy Considerations
HTTP clients can expose a variety of information to servers. Besides HTTP clients can expose a variety of information to servers. Besides
information that's explicitly sent as part of an application's information that's explicitly sent as part of an application's
operation (for example, names and other user-entered data), and "on operation (for example, names and other user-entered data), and "on
the wire" (which is one of the reasons https is recommended in the wire" (which is one of the reasons https is recommended in
Section 4.4.2), other information can be gathered through less Section 4.4.2), other information can be gathered through less
obvious means - often by connecting activities of a user over time. obvious means -- often by connecting activities of a user over time.
This includes session information, tracking the client through This includes session information, tracking the client through
fingerprinting, and mobile code. fingerprinting, and mobile code.
Session information includes things like the IP address of the Session information includes things like the IP address of the
client, TLS session tickets, Cookies, ETags stored in the client's client, TLS session tickets, Cookies, ETags stored in the client's
cache, and other stateful mechanisms. Applications are advised to cache, and other stateful mechanisms. Applications are advised to
avoid using session mechanisms unless they are unavoidable or avoid using session mechanisms unless they are unavoidable or
necessary for operation, in which case these risks needs to be necessary for operation, in which case these risks needs to be
documented. When they are used, implementations should be encouraged documented. When they are used, implementations should be encouraged
to allow clearing such state. to allow clearing such state.
Fingerprinting uses unique aspects of a client's messages and Fingerprinting uses unique aspects of a client's messages and
behaviours to connect disparate requests and connections. For behaviours to connect disparate requests and connections. For
example, the User-Agent request header conveys specific information example, the User-Agent request header field conveys specific
about the implementation; the Accept-Language request header conveys information about the implementation; the Accept-Language request
the users' preferred language. In combination, a number of these header field conveys the users' preferred language. In combination,
markers can be used to uniquely identify a client, impacting its a number of these markers can be used to uniquely identify a client,
control over its data. As a result, applications are advised to impacting its control over its data. As a result, applications are
specify that clients should only emit the information they need to advised to specify that clients should only emit the information they
function in requests. need to function in requests.
Finally, if an application exposes the ability to run mobile code, Finally, if an application exposes the ability to run mobile code,
great care needs to be taken, since any ability to observe its great care needs to be taken, since any ability to observe its
environment can be used as an opportunity to both fingerprint the environment can be used as an opportunity to both fingerprint the
client and to obtain and manipulate private data (including session client and to obtain and manipulate private data (including session
information). For example, access to high-resolution timers (even information). For example, access to high-resolution timers (even
indirectly) can be used to profile the underlying hardware, creating indirectly) can be used to profile the underlying hardware, creating
a unique identifier for the system. Applications are advised to a unique identifier for the system. Applications are advised to
avoid allowing the use of mobile code where possible; when it cannot avoid allowing the use of mobile code where possible; when it cannot
be avoided, the resulting system's security properties need be be avoided, the resulting system's security properties need be
carefully scrutinised. carefully scrutinised.
7. References --- back
7.1. Normative References # Changes from RFC 3205
[I-D.ietf-httpbis-cache] [RFC3205] captured the Best Current Practice in the early 2000's,
Fielding, R., Nottingham, M., and J. Reschke, "HTTP based on the concerns facing protocol designers at the time. Use of
Caching", draft-ietf-httpbis-cache-05 (work in progress), HTTP has changed considerably since then, and as a result this
July 2019. document is substantially different. As a result, the changes are
too numerous to list individually.
[I-D.ietf-httpbis-messaging] 7. References
Fielding, R., Nottingham, M., and J. Reschke, "HTTP/1.1
Messaging", draft-ietf-httpbis-messaging-05 (work in
progress), July 2019.
[I-D.ietf-httpbis-semantics] 7.1. Normative References
Fielding, R., Nottingham, M., and J. Reschke, "HTTP
Semantics", draft-ietf-httpbis-semantics-05 (work in
progress), July 2019.
[I-D.nottingham-rfc5785bis] [I-D.ietf-httpbis-semantics]
Nottingham, M., "Well-Known Uniform Resource Identifiers Fielding, R. T., Nottingham, M., and J. Reschke, "HTTP
(URIs)", draft-nottingham-rfc5785bis-11 (work in Semantics", draft-ietf-httpbis-semantics-14 (work in
progress), April 2019. progress), January 2021.
[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
Requirement Levels", BCP 14, RFC 2119, Requirement Levels", BCP 14, RFC 2119,
DOI 10.17487/RFC2119, March 1997, DOI 10.17487/RFC2119, March 1997,
<https://www.rfc-editor.org/info/rfc2119>. <https://www.rfc-editor.org/info/rfc2119>.
[RFC2818] Rescorla, E., "HTTP Over TLS", RFC 2818,
DOI 10.17487/RFC2818, May 2000,
<https://www.rfc-editor.org/info/rfc2818>.
[RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform
Resource Identifier (URI): Generic Syntax", STD 66, Resource Identifier (URI): Generic Syntax", STD 66,
RFC 3986, DOI 10.17487/RFC3986, January 2005, RFC 3986, DOI 10.17487/RFC3986, January 2005,
<https://www.rfc-editor.org/info/rfc3986>. <https://www.rfc-editor.org/info/rfc3986>.
[RFC6454] Barth, A., "The Web Origin Concept", RFC 6454, [RFC6454] Barth, A., "The Web Origin Concept", RFC 6454,
DOI 10.17487/RFC6454, December 2011, DOI 10.17487/RFC6454, December 2011,
<https://www.rfc-editor.org/info/rfc6454>. <https://www.rfc-editor.org/info/rfc6454>.
[RFC6648] Saint-Andre, P., Crocker, D., and M. Nottingham, [RFC6648] Saint-Andre, P., Crocker, D., and M. Nottingham,
skipping to change at page 29, line 10 skipping to change at page 28, line 10
[RFC6838] Freed, N., Klensin, J., and T. Hansen, "Media Type [RFC6838] Freed, N., Klensin, J., and T. Hansen, "Media Type
Specifications and Registration Procedures", BCP 13, Specifications and Registration Procedures", BCP 13,
RFC 6838, DOI 10.17487/RFC6838, January 2013, RFC 6838, DOI 10.17487/RFC6838, January 2013,
<https://www.rfc-editor.org/info/rfc6838>. <https://www.rfc-editor.org/info/rfc6838>.
[RFC7301] Friedl, S., Popov, A., Langley, A., and E. Stephan, [RFC7301] Friedl, S., Popov, A., Langley, A., and E. Stephan,
"Transport Layer Security (TLS) Application-Layer Protocol "Transport Layer Security (TLS) Application-Layer Protocol
Negotiation Extension", RFC 7301, DOI 10.17487/RFC7301, Negotiation Extension", RFC 7301, DOI 10.17487/RFC7301,
July 2014, <https://www.rfc-editor.org/info/rfc7301>. July 2014, <https://www.rfc-editor.org/info/rfc7301>.
[RFC7320] Nottingham, M., "URI Design and Ownership", BCP 190,
RFC 7320, DOI 10.17487/RFC7320, July 2014,
<https://www.rfc-editor.org/info/rfc7320>.
[RFC7540] Belshe, M., Peon, R., and M. Thomson, Ed., "Hypertext
Transfer Protocol Version 2 (HTTP/2)", RFC 7540,
DOI 10.17487/RFC7540, May 2015,
<https://www.rfc-editor.org/info/rfc7540>.
[RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC
2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174,
May 2017, <https://www.rfc-editor.org/info/rfc8174>. May 2017, <https://www.rfc-editor.org/info/rfc8174>.
[RFC8288] Nottingham, M., "Web Linking", RFC 8288, [RFC8288] Nottingham, M., "Web Linking", RFC 8288,
DOI 10.17487/RFC8288, October 2017, DOI 10.17487/RFC8288, October 2017,
<https://www.rfc-editor.org/info/rfc8288>. <https://www.rfc-editor.org/info/rfc8288>.
[RFC8615] Nottingham, M., "Well-Known Uniform Resource Identifiers
(URIs)", RFC 8615, DOI 10.17487/RFC8615, May 2019,
<https://www.rfc-editor.org/info/rfc8615>.
[RFC8820] Nottingham, M., "URI Design and Ownership", BCP 190,
RFC 8820, DOI 10.17487/RFC8820, June 2020,
<https://www.rfc-editor.org/info/rfc8820>.
7.2. Informative References 7.2. Informative References
[CSP] West, M., "Content Security Policy Level 3", World Wide [CSP] West, M., "Content Security Policy Level 3", World Wide
Web Consortium WD WD-CSP3-20160913, September 2016, Web Consortium WD WD-CSP3-20160913, September 2016,
<https://www.w3.org/TR/2016/WD-CSP3-20160913>. <https://www.w3.org/TR/2016/WD-CSP3-20160913>.
[FETCH] WHATWG, "Fetch - Living Standard", n.d., [FETCH] WHATWG, "Fetch - Living Standard", n.d.,
<https://fetch.spec.whatwg.org>. <https://fetch.spec.whatwg.org>.
[HTML] WHATWG, "HTML - Living Standard", n.d., [HTML] WHATWG, "HTML - Living Standard", n.d.,
<https://html.spec.whatwg.org>. <https://html.spec.whatwg.org>.
[I-D.ietf-httpbis-cache]
Fielding, R. T., Nottingham, M., and J. Reschke, "HTTP
Caching", draft-ietf-httpbis-cache-14 (work in progress),
January 2021.
[I-D.ietf-httpbis-header-structure] [I-D.ietf-httpbis-header-structure]
Nottingham, M. and P. Kamp, "Structured Headers for HTTP", Nottingham, M. and P. Kamp, "Structured Field Values for
draft-ietf-httpbis-header-structure-13 (work in progress), HTTP", draft-ietf-httpbis-header-structure-19 (work in
August 2019. progress), June 2020.
[I-D.ietf-httpbis-rfc6265bis] [I-D.ietf-httpbis-rfc6265bis]
Barth, A. and M. West, "Cookies: HTTP State Management West, M. and J. Wilander, "Cookies: HTTP State Management
Mechanism", draft-ietf-httpbis-rfc6265bis-03 (work in Mechanism", draft-ietf-httpbis-rfc6265bis-07 (work in
progress), April 2019. progress), December 2020.
[REFERRER-POLICY] [REFERRER-POLICY]
Eisinger, J. and E. Stark, "Referrer Policy", World Wide Eisinger, J. and E. Stark, "Referrer Policy", World Wide
Web Consortium CR CR-referrer-policy-20170126, January Web Consortium CR CR-referrer-policy-20170126, January
2017, 2017,
<https://www.w3.org/TR/2017/CR-referrer-policy-20170126>. <https://www.w3.org/TR/2017/CR-referrer-policy-20170126>.
[RFC3205] Moore, K., "On the use of HTTP as a Substrate", BCP 56, [RFC3205] Moore, K., "On the use of HTTP as a Substrate", BCP 56,
RFC 3205, DOI 10.17487/RFC3205, February 2002, RFC 3205, DOI 10.17487/RFC3205, February 2002,
<https://www.rfc-editor.org/info/rfc3205>. <https://www.rfc-editor.org/info/rfc3205>.
skipping to change at page 31, line 9 skipping to change at page 30, line 9
<https://www.rfc-editor.org/info/rfc6797>. <https://www.rfc-editor.org/info/rfc6797>.
[RFC7049] Bormann, C. and P. Hoffman, "Concise Binary Object [RFC7049] Bormann, C. and P. Hoffman, "Concise Binary Object
Representation (CBOR)", RFC 7049, DOI 10.17487/RFC7049, Representation (CBOR)", RFC 7049, DOI 10.17487/RFC7049,
October 2013, <https://www.rfc-editor.org/info/rfc7049>. October 2013, <https://www.rfc-editor.org/info/rfc7049>.
[RFC7258] Farrell, S. and H. Tschofenig, "Pervasive Monitoring Is an [RFC7258] Farrell, S. and H. Tschofenig, "Pervasive Monitoring Is an
Attack", BCP 188, RFC 7258, DOI 10.17487/RFC7258, May Attack", BCP 188, RFC 7258, DOI 10.17487/RFC7258, May
2014, <https://www.rfc-editor.org/info/rfc7258>. 2014, <https://www.rfc-editor.org/info/rfc7258>.
[RFC7540] Belshe, M., Peon, R., and M. Thomson, Ed., "Hypertext
Transfer Protocol Version 2 (HTTP/2)", RFC 7540,
DOI 10.17487/RFC7540, May 2015,
<https://www.rfc-editor.org/info/rfc7540>.
[RFC7595] Thaler, D., Ed., Hansen, T., and T. Hardie, "Guidelines [RFC7595] Thaler, D., Ed., Hansen, T., and T. Hardie, "Guidelines
and Registration Procedures for URI Schemes", BCP 35, and Registration Procedures for URI Schemes", BCP 35,
RFC 7595, DOI 10.17487/RFC7595, June 2015, RFC 7595, DOI 10.17487/RFC7595, June 2015,
<https://www.rfc-editor.org/info/rfc7595>. <https://www.rfc-editor.org/info/rfc7595>.
[RFC7605] Touch, J., "Recommendations on Using Assigned Transport [RFC7605] Touch, J., "Recommendations on Using Assigned Transport
Port Numbers", BCP 165, RFC 7605, DOI 10.17487/RFC7605, Port Numbers", BCP 165, RFC 7605, DOI 10.17487/RFC7605,
August 2015, <https://www.rfc-editor.org/info/rfc7605>. August 2015, <https://www.rfc-editor.org/info/rfc7605>.
[RFC7616] Shekh-Yusef, R., Ed., Ahrens, D., and S. Bremer, "HTTP [RFC7616] Shekh-Yusef, R., Ed., Ahrens, D., and S. Bremer, "HTTP
skipping to change at page 31, line 48 skipping to change at page 31, line 9
<https://www.rfc-editor.org/info/rfc8297>. <https://www.rfc-editor.org/info/rfc8297>.
[SECCTXT] West, M., "Secure Contexts", World Wide Web Consortium CR [SECCTXT] West, M., "Secure Contexts", World Wide Web Consortium CR
CR-secure-contexts-20160915, September 2016, CR-secure-contexts-20160915, September 2016,
<https://www.w3.org/TR/2016/CR-secure-contexts-20160915>. <https://www.w3.org/TR/2016/CR-secure-contexts-20160915>.
[XML] Bray, T., Paoli, J., Sperberg-McQueen, M., Maler, E., and [XML] Bray, T., Paoli, J., Sperberg-McQueen, M., Maler, E., and
F. Yergeau, "Extensible Markup Language (XML) 1.0 (Fifth F. Yergeau, "Extensible Markup Language (XML) 1.0 (Fifth
Edition)", World Wide Web Consortium Recommendation REC- Edition)", World Wide Web Consortium Recommendation REC-
xml-20081126, November 2008, xml-20081126, November 2008,
<http://www.w3.org/TR/2008/REC-xml-20081126>. <https://www.w3.org/TR/2008/REC-xml-20081126>.
7.3. URIs 7.3. URIs
[1] https://lists.w3.org/Archives/Public/ietf-http-wg/ [1] https://lists.w3.org/Archives/Public/ietf-http-wg/
[2] http://httpwg.github.io/ [2] http://httpwg.github.io/
[3] https://github.com/httpwg/http-extensions/labels/bcp56bis [3] https://github.com/httpwg/http-extensions/labels/bcp56bis
Appendix A. Changes from RFC 3205
[RFC3205] captured the Best Current Practice in the early 2000's,
based on the concerns facing protocol designers at the time. Use of
HTTP has changed considerably since then, and as a result this
document is substantially different. As a result, the changes are
too numerous to list individually.
Author's Address Author's Address
Mark Nottingham Mark Nottingham
Prahran, VIC
Australia
Email: mnot@mnot.net Email: mnot@mnot.net
URI: https://www.mnot.net/ URI: https://www.mnot.net/
 End of changes. 88 change blocks. 
238 lines changed or deleted 186 lines changed or added

This html diff was produced by rfcdiff 1.44jr. The latest version is available from http://tools.ietf.org/tools/rfcdiff/