draft-ietf-httpbis-bcp56bis-07.txt   draft-ietf-httpbis-bcp56bis-08.txt 
HTTP M. Nottingham HTTP M. Nottingham
Internet-Draft October 21, 2018 Internet-Draft November 9, 2018
Obsoletes: 3205 (if approved) Obsoletes: 3205 (if approved)
Intended status: Best Current Practice Intended status: Best Current Practice
Expires: April 24, 2019 Expires: May 13, 2019
Building Protocols with HTTP Building Protocols with HTTP
draft-ietf-httpbis-bcp56bis-07 draft-ietf-httpbis-bcp56bis-08
Abstract Abstract
HTTP is often used as a substrate for other application protocols HTTP is often used as a substrate for other application protocols
(a.k.a. HTTP-based APIs). This document specifies best practices (a.k.a. HTTP-based APIs). This document specifies best practices
for such protocols' use of HTTP when they are defined for diverse for such protocols' use of HTTP 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
skipping to change at page 1, line 44 skipping to change at page 1, line 44
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 April 24, 2019. This Internet-Draft will expire on May 13, 2019.
Copyright Notice Copyright Notice
Copyright (c) 2018 IETF Trust and the persons identified as the Copyright (c) 2018 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
skipping to change at page 2, line 46 skipping to change at page 2, line 46
4.4.3. Transport Ports . . . . . . . . . . . . . . . . . . . 12 4.4.3. Transport Ports . . . . . . . . . . . . . . . . . . . 12
4.5. HTTP Methods . . . . . . . . . . . . . . . . . . . . . . 13 4.5. HTTP Methods . . . . . . . . . . . . . . . . . . . . . . 13
4.5.1. GET . . . . . . . . . . . . . . . . . . . . . . . . . 13 4.5.1. GET . . . . . . . . . . . . . . . . . . . . . . . . . 13
4.5.2. OPTIONS . . . . . . . . . . . . . . . . . . . . . . . 14 4.5.2. OPTIONS . . . . . . . . . . . . . . . . . . . . . . . 14
4.6. HTTP Status Codes . . . . . . . . . . . . . . . . . . . . 15 4.6. HTTP Status Codes . . . . . . . . . . . . . . . . . . . . 15
4.6.1. Redirection . . . . . . . . . . . . . . . . . . . . . 16 4.6.1. Redirection . . . . . . . . . . . . . . . . . . . . . 16
4.7. HTTP Header Fields . . . . . . . . . . . . . . . . . . . 17 4.7. HTTP Header Fields . . . . . . . . . . . . . . . . . . . 17
4.8. Defining Message Payloads . . . . . . . . . . . . . . . . 18 4.8. Defining Message Payloads . . . . . . . . . . . . . . . . 18
4.9. HTTP Caching . . . . . . . . . . . . . . . . . . . . . . 18 4.9. HTTP Caching . . . . . . . . . . . . . . . . . . . . . . 18
4.10. Application State . . . . . . . . . . . . . . . . . . . . 20 4.10. Application State . . . . . . . . . . . . . . . . . . . . 20
4.11. Client Authentication . . . . . . . . . . . . . . . . . . 20 4.11. Client Authentication . . . . . . . . . . . . . . . . . . 21
4.12. Co-Existing with Web Browsing . . . . . . . . . . . . . . 21 4.12. Co-Existing with Web Browsing . . . . . . . . . . . . . . 21
4.13. Application Boundaries . . . . . . . . . . . . . . . . . 22 4.13. Application Boundaries . . . . . . . . . . . . . . . . . 23
4.14. Server Push . . . . . . . . . . . . . . . . . . . . . . . 23 4.14. Server Push . . . . . . . . . . . . . . . . . . . . . . . 23
4.15. Versioning and Evolution . . . . . . . . . . . . . . . . 24 4.15. Versioning and Evolution . . . . . . . . . . . . . . . . 24
5. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 24 5. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 25
6. Security Considerations . . . . . . . . . . . . . . . . . . . 24 6. Security Considerations . . . . . . . . . . . . . . . . . . . 25
6.1. Privacy Considerations . . . . . . . . . . . . . . . . . 25 6.1. Privacy Considerations . . . . . . . . . . . . . . . . . 25
7. References . . . . . . . . . . . . . . . . . . . . . . . . . 26 7. References . . . . . . . . . . . . . . . . . . . . . . . . . 26
7.1. Normative References . . . . . . . . . . . . . . . . . . 26 7.1. Normative References . . . . . . . . . . . . . . . . . . 26
7.2. Informative References . . . . . . . . . . . . . . . . . 27 7.2. Informative References . . . . . . . . . . . . . . . . . 27
7.3. URIs . . . . . . . . . . . . . . . . . . . . . . . . . . 30 7.3. URIs . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Appendix A. Changes from RFC 3205 . . . . . . . . . . . . . . . 30 Appendix A. Changes from RFC 3205 . . . . . . . . . . . . . . . 30
Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 30 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 30
1. Introduction 1. Introduction
HTTP [RFC7230] is often used as a substrate for applications other HTTP [I-D.ietf-httpbis-semantics] is often used as a substrate for
than Web browsing; this is sometimes referred to as creating "HTTP- applications other than Web browsing; this is sometimes referred to
based APIs", or just "HTTP APIs". This is done for a variety of as creating "HTTP-based APIs", or just "HTTP APIs". This is done for
reasons, including: a variety of reasons, including:
o familiarity by implementers, specifiers, administrators, o familiarity by implementers, specifiers, administrators,
developers and users, developers and users,
o availability of a variety of client, server and proxy o availability of a variety of client, server and proxy
implementations, implementations,
o ease of use, o ease of use,
o availability of Web browsers, o availability of Web browsers,
skipping to change at page 3, line 47 skipping to change at page 3, line 47
of clients. Perhaps because of the factors cited above, a body of of clients. Perhaps because of the factors cited above, a body of
practices and tools has arisen around defining HTTP-based APIs that practices and tools has arisen around defining HTTP-based APIs that
favours these conditions. favours these conditions.
However, when such an application has multiple, separate However, when such an application has multiple, separate
implementations of the server component, is deployed on multiple implementations of the server component, is deployed on multiple
uncoordinated servers, and is consumed by diverse clients - as is uncoordinated servers, and is consumed by diverse clients - as is
often the case for standards efforts to define new HTTP APIs - tools often the case for standards efforts to define new HTTP APIs - tools
and practices intended for limited deployment can become unsuitable. and practices intended for limited deployment can become unsuitable.
For example, because implementations (both client and server) will This is largely because implementations (both client and server) will
implement and evolve at different paces, a HTTP-based API might need implement and evolve at different paces. As a result, such an HTTP-
to more carefully consider how extensibility of the service will be based API will need to more carefully consider how extensibility of
handled, and how different deployment requirements will be the service will be handled and how different deployment requirements
accommodated. will be accommodated.
More generally, application protocols using HTTP face a number of More generally, application protocols using HTTP face a number of
design decisions, including: design decisions, including:
o Should it define a new URL scheme? Use new ports? o Should it define a new URL 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?
skipping to change at page 4, line 42 skipping to change at page 4, line 42
1.1. Notational Conventions 1.1. Notational Conventions
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and
"OPTIONAL" in this document are to be interpreted as described in BCP "OPTIONAL" in this document are to be interpreted as described in BCP
14 [RFC2119] [RFC8174] when, and only when, they appear in all 14 [RFC2119] [RFC8174] when, and only when, they appear in all
capitals, as shown here. capitals, as shown here.
2. Is HTTP Being Used? 2. Is HTTP Being Used?
Different applications have different goals when using HTTP. In this Different applications have different goals when using HTTP. The
document, we say an application is "using HTTP" when any of the requirements in this document apply when any of the following
following conditions are true: conditions are true:
o The transport port in use is 80 or 443, o The transport port in use is 80 or 443,
o The URL scheme "http" or "https" is used, o The URL scheme "http" or "https" is used,
o The ALPN protocol ID [RFC7301] generically identifies HTTP (e.g., o The ALPN protocol ID [RFC7301] generically identifies HTTP (e.g.,
"http/1.1", "h2", "h2c"), or "http/1.1", "h2", "h2c"), or
o The IANA registries defined for HTTP are updated or modified. o The IANA registries defined for HTTP are updated or modified.
When an application is using HTTP, all of the requirements of the When an application is using HTTP, all of the requirements of the
HTTP protocol suite are in force (including but not limited to HTTP protocol suite are in force (including but not limited to
[RFC7230], [RFC7231], [RFC7232], [RFC7233], [RFC7234], [RFC7235] and [I-D.ietf-httpbis-semantics], [I-D.ietf-httpbis-cache],
[RFC7540]). [I-D.ietf-httpbis-messaging], and [RFC7540]).
An application might not be using HTTP according to this definition, An application might not use HTTP according to this definition and
but still relying upon the HTTP specifications in some manner. For still rely upon the HTTP specifications in some manner. For example,
example, an application might wish to avoid re-specifying parts of an application might wish to avoid re-specifying parts of the message
the message format, but change others; or, it might want to use a format, but change others; or, it might want to use a different set
different set of methods. of methods.
Such applications are referred to as "protocols based upon HTTP" in Such applications are referred to as "protocols based upon HTTP" in
this document. These have more freedom to modify protocol this document. These have more freedom to modify protocol
operations, but are also likely to lose at least a portion of the operations, but are also likely to lose at least a portion of the
benefits outlined above, as most HTTP implementations won't be easily benefits outlined above, as most HTTP implementations won't be easily
adaptable to these changes, and as the protocol diverges from HTTP, adaptable to these changes, and as the protocol diverges from HTTP,
the benefit of mindshare will be lost. the benefit of mindshare will be lost.
Protocols that are based upon HTTP MUST NOT reuse HTTP's URL schemes, Protocols that are based upon HTTP MUST NOT reuse HTTP's URL schemes,
transport ports, ALPN protocol IDs or IANA registries; rather, they transport ports, ALPN protocol IDs or IANA registries; rather, they
are encouraged to establish their own. are encouraged to establish their own.
3. What's Important About HTTP 3. What's Important About HTTP
There are many ways that applications using HTTP are defined and Applications using HTTP are defined and deployed in many ways;
deployed, and sometimes they are brought to the IETF for sometimes they are brought to the IETF for standardisation. What
standardisation. In that process, what might be workable for might be workable for deployment in a limited fashion isn't
deployment in a limited fashion isn't appropriate for standardisation appropriate for standardisation and the corresponding broader
and the corresponding broader deployment. deployment.
This section examines the facets of the protocol that are important This section examines the facets of the protocol that are important
to preserve in these situations. to preserve in these situations.
3.1. Generic Semantics 3.1. Generic Semantics
When writing an application's 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 However, this can easily lead to an unintended profile of HTTP's
behaviour. For example, it's common to see specifications with behaviour. For example, it's common to see specifications with
language like this: 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. If the client does status code might differ in a real deployment. If the client does
not anticipate this, the application's deployment is brittle. not anticipate this, the application's deployment is brittle.
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 expressed in the payload; mostly, in the body, but also semantics are expressed in the payload; mostly, in the body, but also
in header fields. in header fields.
This allows a HTTP message to be examined by generic HTTP software This allows a HTTP message to be examined by generic software (e.g.,
(e.g., HTTP servers, intermediaries, client implementations), and its HTTP servers, intermediaries, client implementations, and caches) and
handling to be correctly determined. It also allows people to its handling to be correctly determined. It also allows people to
leverage their knowledge of HTTP semantics without special-casing leverage their knowledge of HTTP semantics without special-casing
them for a particular application. them for a particular 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 defined protocol elements. Instead, they overlay the semantics of defined protocol elements. Instead, they
should focus their specifications on protocol elements that are should focus their specifications on protocol elements that are
specific to that application; namely their HTTP resources. specific to that application; namely their HTTP resources.
See Section 4.2 for details. See Section 4.2 for details.
skipping to change at page 8, line 13 skipping to change at page 8, line 13
is a good starting point. is a good starting point.
4. Best Practices for Using HTTP 4. Best Practices for Using HTTP
This section contains best practices regarding the use of HTTP by This section contains best practices regarding the use of HTTP by
applications, including practices for specific HTTP protocol applications, including practices for specific HTTP protocol
elements. elements.
4.1. Specifying the Use of HTTP 4.1. Specifying the Use of HTTP
When specifying the use of HTTP, an application SHOULD use [RFC7230] When specifying the use of HTTP, an application SHOULD use
as the primary reference; it is not necessary to reference all of the [I-D.ietf-httpbis-semantics] as the primary reference; it is not
specifications in the HTTP suite unless there are specific reasons to necessary to reference all of the specifications in the HTTP suite
do so (e.g., a particular feature is called out). unless there are specific reasons to do so (e.g., a particular
feature is called out).
Applications using HTTP SHOULD NOT specify a minimum version of HTTP Applications using HTTP SHOULD NOT specify a minimum version of HTTP
to be used; because it is a hop-by-hop protocol, a HTTP connection to be used; because it is a hop-by-hop protocol, a HTTP connection
can be handled by implementations that are not controlled by the can be handled by implementations that are not controlled by the
application; for example, proxies, CDNs, firewalls and so on. application; for example, proxies, CDNs, firewalls and so on.
Requiring a particular version of HTTP makes it difficult to use in Requiring a particular version of HTTP makes it difficult to use in
these situations, and harms interoperability for little reason (since these situations, and harms interoperability for little reason (since
HTTP's semantics are stable between protocol versions). HTTP's semantics are stable between protocol versions).
However, if an application's deployment would benefit from the use of However, if an application's deployment would benefit from the use of
skipping to change at page 9, line 50 skipping to change at page 9, line 50
The "Example-Count" response header field on Widget representations The "Example-Count" response header field on Widget representations
indicates how many Widgets are held by the sender. indicates how many Widgets are held by the sender.
The "application/example-widget+json" format is a JSON [RFC8259] The "application/example-widget+json" format is a JSON [RFC8259]
format representing the state of a Widget. It contains links to format representing the state of a Widget. It contains links to
related information in the link indicated by the Link header field related information in the link indicated by the Link header field
value with the "example-other-info" link relation type. value with the "example-other-info" link relation type.
4.3. Specifying Client Behaviours 4.3. Specifying Client Behaviours
HTTP does not mandate some behaviours that have nevertheless become Some behaviours (e.g., automatic redirect handling) and extensions
very common; if these are not explicitly specified by applications (e.g., Cookies) are not required by HTTP, but nevertheless have
become very common, possibly because they are supported by Web
browsers. If their use is not explicitly specified by applications
using HTTP, there may be confusion and interoperability problems. using HTTP, there may be confusion and interoperability problems.
This section recommends default handling for these mechanisms. This section recommends default handling for these mechanisms.
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 MUST explicitly reference the o Cookies - Applications using HTTP MUST explicitly reference the
Cookie specification [RFC6265] if they are required. Cookie specification [I-D.ietf-httpbis-rfc6265bis] if they are
required.
o Certificates - Applications using HTTP MUST specify that TLS o Certificates - Applications using HTTP MUST specify that TLS
certificates are to be checked according to [RFC2818] when HTTPS certificates are to be checked according to [RFC2818] when HTTPS
is used. is used.
In general, applications using HTTP ought to align their usage as In general, applications using HTTP ought to align their usage as
closely as possible with Web browsers, to avoid interoperability closely as possible with Web browsers, to avoid interoperability
issues when they are used. See Section 4.12. issues when they are used. See Section 4.12.
If an application using HTTP has browser compatibility as a goal, If an application using HTTP has browser compatibility as a goal,
client interaction ought to be defined in terms of [FETCH], since client interaction ought to be defined in terms of [FETCH], since
that is the abstraction that browsers use for HTTP; it enforces many that is the abstraction that browsers use for HTTP; it enforces many
of these best practices. of these best practices.
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. For example, requiring that usually negotiated to be supported by clients. For example,
clients support responses with a certain content-encoding ([RFC7231], requiring that clients support responses with a certain content-
Section 3.1.2.2) instead of negotiating for it ([RFC7231], coding ([I-D.ietf-httpbis-semantics], Section 6.2.2) instead of
Section 5.3.4) means that otherwise conformant clients cannot negotiating for it ({{?I-D.ietf-httpbis-semantics, Section 8.4.4)
interoperate with the application. Applications MAY encourage the means that otherwise conformant clients cannot interoperate with the
implementation of such features, though. application. Applications MAY encourage the implementation of such
features, though.
4.4. HTTP URLs 4.4. HTTP URLs
In HTTP, URLs are opaque identifiers under the control of the server. In HTTP, URLs are opaque identifiers under the control of the server.
As outlined in [RFC7320], standards cannot usurp this space, since it As outlined in [RFC7320], standards cannot usurp this space, since it
might conflict with existing resources, and constrain implementation might conflict with existing resources, and constrain implementation
and deployment. and deployment.
In other words, applications that use HTTP shouldn't associate In other words, applications that use HTTP shouldn't associate
application semantics with specific URL paths on arbitrary servers. application semantics with specific URL paths on arbitrary servers.
Doing so inappropriately conflates the identity of the resource (its Doing so inappropriately conflates the identity of the resource (its
URL) with the capabilities that resource supports, bringing about URL) with the capabilities that resource supports, bringing about
many of the same interoperability problems that [RFC4367] warns of. many of the same interoperability problems that [RFC4367] warns of.
For example, specifying that a "GET to the URL /foo retrieves a bar For example, specifying that a "GET to the URL /foo retrieves a bar
document" is bad practice. Likewise, specifying "The widget API is document" is bad practice. Likewise, specifying "The widget API is
at the path /bar" violates [RFC7320]. at the path /bar" violates [RFC7320].
Instead, applications that use HTTP are encouraged to ensure that Instead, applications are encouraged to ensure that URLs are
URLs are discovered at runtime, allowing HTTP-based services to discovered at runtime, allowing HTTP-based services to describe their
describe their own capabilities. One way to do this is to use typed own capabilities. One way to do this is to use typed links [RFC8288]
links [RFC8288] to convey the URIs that are in use, as well as the to convey the URIs that are in use, as well as the semantics of the
semantics of the resources that they identify. See Section 4.2 for resources that they identify. See Section 4.2 for details.
details.
4.4.1. Initial URL Discovery 4.4.1. Initial URL Discovery
Generally, a client will begin interacting with a given application Generally, a client will begin interacting with a given application
server by requesting an initial document that contains information server by requesting an initial document that contains information
about that particular deployment, potentially including links to about that particular deployment, potentially including links to
other relevant resources. other relevant resources.
Applications that use HTTP are encouraged to allow an arbitrary URL Applications are encouraged to allow an arbitrary URL to be used as
to be used as that entry point. For example, rather than specifying that entry point. For example, rather than specifying "the initial
"the initial document is at "/foo/v1", they should allow a deployment document is at "/foo/v1", they should allow a deployment to use any
to use any URL as the entry point for the application. URL as the entry point for the application.
In cases where doing so is impractical (e.g., it is not possible to In cases where doing so is impractical (e.g., it is not possible to
convey a whole URL, but only a hostname) standard applications that convey a whole URL, but only a hostname) applications can request a
use HTTP can request a well-known URL [RFC5785] as an entry point. well-known URL [I-D.nottingham-rfc5785bis] as an entry point.
4.4.2. URL Schemes 4.4.2. URL Schemes
Applications that use HTTP will typically employ the "http" and/or Applications that use HTTP will typically employ the "http" and/or
"https" URL schemes. "https" is RECOMMENDED to provide "https" URL schemes. "https" is RECOMMENDED to provide
authentication, integrity and confidentiality, as well as mitigate authentication, integrity and confidentiality, as well as mitigate
pervasive monitoring attacks [RFC7258]. pervasive monitoring attacks [RFC7258].
However, application-specific schemes can be defined as well. However, application-specific schemes can also be defined. When
defining an URL scheme for an application using HTTP, there are a
When defining an URL scheme for an application using HTTP, there are number of tradeoffs and caveats to keep in mind:
a number of tradeoffs and caveats to keep in mind:
o Unmodified Web browsers will not support the new scheme. While it o Unmodified Web browsers will not support the new scheme. While it
is possible to register new URL schemes with Web browsers (e.g. is possible to register new URL schemes with Web browsers (e.g.
registerProtocolHandler() in [HTML5], as well as several registerProtocolHandler() in [HTML5], as well as several
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
skipping to change at page 12, line 19 skipping to change at page 12, line 19
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.
o HTTP-specific features such as cookies [RFC6265], authentication o HTTP-specific features such as cookies
[RFC7235], caching [RFC7234], HSTS [RFC6797], and CORS [FETCH] [I-D.ietf-httpbis-rfc6265bis], authentication
might or might not work correctly, depending on how they are [I-D.ietf-httpbis-semantics], caching [I-D.ietf-httpbis-cache],
defined and implemented. Generally, they are designed and HSTS [RFC6797], and CORS [FETCH] might or might not work
implemented with an assumption that the URL will always be "http" correctly, depending on how they are defined and implemented.
or "https". Generally, they are designed and implemented with an assumption
that the URL will always be "http" or "https".
o Web features that require a secure context [SECCTXT] will likely o Web features that require a secure context [SECCTXT] will likely
treat a new scheme as insecure. treat a new scheme as insecure.
See [RFC7595] for more information about minting new URL schemes. See [RFC7595] for more information about minting new URL schemes.
4.4.3. Transport Ports 4.4.3. Transport Ports
Applications that use HTTP can use the applicable default port (80 Applications can use the applicable default port (80 for HTTP, 443
for HTTP, 443 for HTTPS), or they can be deployed upon other ports. for HTTPS), or they can be deployed upon other ports. This decision
This decision can be made at deployment time, or might be encouraged can be made at deployment time, or might be encouraged by the
by the application's specification (e.g., by registering a port for application's specification (e.g., by registering a port for that
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 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. HTTP Methods 4.5. HTTP Methods
Applications that use HTTP MUST confine themselves to using Applications that use HTTP MUST confine themselves to using
registered HTTP methods such as GET, POST, PUT, DELETE, and PATCH. registered HTTP methods such as GET, POST, PUT, DELETE, and PATCH.
New HTTP methods are rare; they are required to be registered in the New HTTP methods are rare; they are required to be registered in the
HTTP Method Registry with IETF Review (see [RFC7231]), and are also HTTP Method Registry with IETF Review (see
required to be generic. That means that they need to be potentially [I-D.ietf-httpbis-semantics]), and are also required to be generic.
applicable to all resources, not just those of one application. That means that they need to be potentially applicable to all
resources, not just those of one application.
While historically some applications (e.g., [RFC4791]) have defined While historically some applications (e.g., [RFC4791]) have defined
non-generic methods, [RFC7231] now forbids this. non-generic methods, [I-D.ietf-httpbis-semantics] now forbids this.
When authors believe that a new method is required, they are When authors believe that a new method 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.5.1. GET 4.5.1. GET
GET is one of the most common and useful HTTP methods; its retrieval GET is one of the most common and useful HTTP methods; its retrieval
semantics allow caching, side-effect free linking and forms the basis semantics allow caching, side-effect free linking and underlies many
of many of the benefits of using HTTP. of the benefits of using HTTP.
A common use of GET is to perform queries, often using the query A common use of GET is to perform queries, often using the query
component of the URL; this is a familiar pattern from Web browsing, component of the URL; this is a familiar pattern from Web browsing,
and the results can be cached, improving efficiency of an often and the results can be cached, improving efficiency of an often
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 URL; in particular, if binary because of the limited syntax of the URL; 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 URL syntax. to URL 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 [RFC7230], Section 3.1.1). 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 body; 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 that use HTTP SHOULD NOT define GET requests to have Applications SHOULD NOT define GET requests to have side effects,
side effects, since implementations can and do retry HTTP GET since implementations can and do retry HTTP GET requests that fail.
requests that fail.
Finally, note that while HTTP allows GET requests to have a body Finally, note that while HTTP allows GET requests to have a body
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 [RFC7231], Section 4.3.1, a body on a GET has no meaning, and per [I-D.ietf-httpbis-semantics], Section 7.3.1, a body on a GET has
will be either ignored or rejected by generic HTTP software. no meaning, and will be either ignored or rejected by generic HTTP
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.
However, OPTIONS does have significant limitations: However, OPTIONS does have significant limitations:
skipping to change at page 14, line 43 skipping to change at page 14, line 45
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 [RFC5785], or o For server-wide metadata, create a well-known URI
using an already existing one if it's appropriate (e.g., HostMeta [I-D.nottingham-rfc5785bis], or using an already existing one if
[RFC6415]). it's appropriate (e.g., HostMeta [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 or a link serialised
into the representation's body. See [RFC8288]. Note that the into the representation's body. See [RFC8288]. Note that the
Link header is available on HEAD responses, which is useful if the Link header is available on HEAD responses, which is useful if the
client wants to discover a resource's capabilities before they client wants to discover a resource's capabilities before they
interact with it. interact with it.
4.6. HTTP Status Codes 4.6. HTTP Status Codes
The primary function of a HTTP status code is to convey semantics for The primary function of a HTTP status code is to convey semantics for
the benefit of generic HTTP software, not to convey application- the benefit of generic HTTP software, not to convey application-
specific semantics. specific semantics.
In particular, status codes are often generated or overwritten by Status codes are often generated or overwritten by intermediaries, as
intermediaries, as well as server and client implementations; for well as server and client implementations. This can happen, for
example, when network errors are encountered, a captive portal is example, when network errors are encountered, a captive portal is
present, when an implementation is overloaded, or it thinks it is present, when an implementation is overloaded, or it thinks it is
under attack. As a result, the status code that a server-side under attack. As a result, the status code that a server-side
application generates and the one that the client software receives application generates and the one that the client software receives
often differ. often differ.
This means that status codes are not a reliable way to carry This means that status codes are not a reliable way to carry
application-specific signals. Specifying that a particular status application-specific signals. Specifying that a particular status
code has a specific meaning in the context of an application can have code has a specific meaning in the context of an application can have
unintended side effects; if that status code is generated by a unintended side effects; if that status code is generated by a
skipping to change at page 15, line 50 skipping to change at page 16, line 5
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 is never complete. of potential status codes, since such a list is never complete.
Applications using HTTP MUST NOT re-specify the semantics of HTTP Applications using HTTP MUST NOT re-specify the semantics of HTTP
status codes, even if it is only by copying their definition. They status codes, even if it is only by copying their definition. They
MUST NOT require specific reason phrases to be used; the reason MUST NOT require specific reason phrases to be used; the reason
phrase has no function in HTTP, and is not guaranteed to be preserved phrase has no function in HTTP, is not guaranteed to be preserved by
by implementations, and the reason phrase is not carried at all in implementations, and the reason phrase is not carried at all in the
the [RFC7540] message format. HTTP/2 [RFC7540] message format.
Applications that use HTTP MUST only use registered HTTP status Applications MUST only use registered HTTP status codes. As with
codes. As with methods, new HTTP status codes are rare, and required methods, new HTTP status codes are rare, and required (by
(by [RFC7231]) to be registered with IETF review. Similarly, HTTP [I-D.ietf-httpbis-semantics]) to be registered with IETF Review.
status codes are generic; they are required (by [RFC7231]) to be Similarly, HTTP status codes are generic; they are required (by
potentially applicable to all resources, not just to those of one [I-D.ietf-httpbis-semantics]) to be potentially applicable to all
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 [RFC7231], Section 6.4 The 3xx series of status codes specified in
are used to direct the user agent to another resource to satisfy the [I-D.ietf-httpbis-semantics], Section 9.4 direct the user agent to
request. The most common of these are 301, 302, 307 and 308 another resource to satisfy the request. The most common of these
([RFC7538]), all of which use the Location response header field to are 301, 302, 307 and 308 ([RFC7538]), all of which use the Location
indicate where the client should send the request to. response 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
skipping to change at page 16, line 47 skipping to change at page 17, line 4
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 [RFC7231], a user agent is allowed to automatically automatically follow a 3xx redirect that has a Location response
follow a 3xx redirect that has a Location response header field, even header field, even if they don't understand the semantics of the
if they don't understand the semantics of the specific status code. specific status code. However, they aren't required to do so;
However, they aren't required to do so; therefore, if an application therefore, if an application using HTTP desires redirects to be
using HTTP desires redirects to be automatically followed, it needs automatically followed, it needs to explicitly specify the
to explicitly specify the circumstances when this is required. circumstances when this is required.
Applications using HTTP SHOULD specify that 301 and 302 responses Applications using HTTP SHOULD specify that 301 and 302 responses
change the subsequent request method from POST (but no other method) change the subsequent request method from POST (but no other method)
to GET, to be compatible with browsers. to GET, to be compatible with browsers.
Generally, when a redirected request is made, its header fields are Generally, when a redirected request is made, its header fields are
copied from the original request's. However, they can be modified by copied from the original request's. However, they can be modified by
various mechanisms; e.g., sent Authorization ([RFC7235]) and Cookie various mechanisms; e.g., sent Authorization
([RFC6265]) headers will change if the origin (and sometimes path) of ([I-D.ietf-httpbis-semantics]) and Cookie
the request changes. Applications using HTTP SHOULD specify if any ([I-D.ietf-httpbis-rfc6265bis]) headers will change if the origin
request headers need to be modified or removed upon a redirect; (and sometimes path) of the request changes. Applications using HTTP
however, this behaviour cannot be relied upon, since a generic client SHOULD specify if any request headers need to be modified or removed
(like a browser) will be unaware of such requirements. upon a redirect; however, this behaviour cannot be relied upon, since
a generic client (like a browser) will be unaware of such
requirements.
4.7. HTTP Header Fields 4.7. HTTP Header Fields
Applications that use HTTP MAY define new HTTP header fields. Applications MAY define new HTTP header fields. Typically, using
Typically, using HTTP header fields is appropriate in a few different HTTP header fields is appropriate in a few different situations:
situations:
o Their content is useful to intermediaries (who often wish to avoid o Their content is useful to intermediaries (who often wish to avoid
parsing the body), and/or parsing the body), and/or
o Their content is useful to generic HTTP software (e.g., clients, o Their content 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 content in the message body
(usually because a format does not allow it). (usually because a format does not allow it).
New header fields MUST be registered, as per [RFC7231] and [RFC3864]. New header fields MUST be registered, as per
[I-D.ietf-httpbis-semantics].
See [RFC7231], Section 8.3.1 for guidelines to consider when minting See [I-D.ietf-httpbis-semantics], Section 4.1.3 for guidelines to
new header fields. [I-D.ietf-httpbis-header-structure] provides a consider when minting new header fields.
common structure for new header fields, and avoids many issues in [I-D.ietf-httpbis-header-structure] provides a common structure for
their parsing and handling; it is RECOMMENDED that new header fields new header fields, and avoids many issues in their parsing and
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 HTTP/2
header compression is in effect, there is an overhead) but header compression is in effect, there is an overhead) but
appropriately specific. In particular, if a header field is specific appropriately specific. In particular, if a header field is specific
to an application, an identifier for that application SHOULD form a to an application, an identifier for that application SHOULD form a
prefix to the header field name, separated by a "-". prefix to 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
skipping to change at page 18, line 33 skipping to change at page 18, line 40
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.
Applications SHOULD register distinct media types for each format Applications SHOULD register distinct media types for each format
they define; this makes it possible to identify them unambiguously they define; this makes it possible to identify them unambiguously
and negotiate for their use. See [RFC6838] for more information. and negotiate for their use. See [RFC6838] for more information.
4.9. HTTP Caching 4.9. HTTP Caching
HTTP caching [RFC7234] is one of the primary benefits of using HTTP HTTP caching [I-D.ietf-httpbis-cache] is one of the primary benefits
for applications; it provides scalability, reduces latency and of using HTTP for applications; it provides scalability, reduces
improves reliability. Furthermore, HTTP caches are readily available latency and improves reliability. Furthermore, HTTP caches are
in browsers and other clients, networks as forward and reverse readily available in browsers and other clients, networks as forward
proxies, Content Delivery Networks and as part of server software. and reverse proxies, Content Delivery Networks and as part of server
software.
Assigning even a short freshness lifetime ([RFC7234], Section 4.2) - Assigning even a short freshness lifetime ([I-D.ietf-httpbis-cache],
e.g., 5 seconds - allows a response to be reused to satisfy multiple Section 4.2) - e.g., 5 seconds - allows a response to be reused to
clients, and/or a single client making the same request repeatedly. satisfy multiple clients, and/or a single client making the same
In general, if it is safe to reuse something, consider assigning a request repeatedly. In general, if it is safe to reuse something,
freshness lifetime; cache implementations take active measures to consider assigning a freshness lifetime; cache implementations take
remove content intelligently when they are out of space, so "it will active measures to remove content intelligently when they are out of
fill up the cache" is not a valid concern. space, so "it will fill up the cache" is not a valid concern.
The most common method for specifying freshness is the max-age The most common method for specifying freshness is the max-age
response directive ([RFC7234], Section 5.2.2.8). The Expires header response directive ([I-D.ietf-httpbis-cache], Section 5.2.2.8). The
([RFC7234], Section 5.3) can also be used, but it is not necessary to Expires header ([I-D.ietf-httpbis-cache], Section 5.3) can also be
specify it; all modern cache implementations support Cache-Control, used, but it is not necessary to specify it; all modern cache
and specifying freshness as a delta is both more convenient in most implementations support Cache-Control, and specifying freshness as a
cases, and less error-prone. delta is usually more convenient and always less error-prone.
Understand that stale responses (e.g., one with "Cache-Control: max- Understand that stale responses (e.g., with "Cache-Control: max-
age=0") can be reused when the cache is disconnected from the origin age=0") can be reused when the cache is disconnected from the origin
server; this can be useful for handling network issues. See server; this can be useful for handling network issues. See
[RFC7234], Section 4.2.4, and also [RFC5861] for additional controls [I-D.ietf-httpbis-cache], Section 4.2.4, and also [RFC5861] for
over stale content. additional controls over stale 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
[RFC7232]. [I-D.ietf-httpbis-semantics].
If an application defines a request header field that might be used If an application uses a request header field to change the
by a server to change the response's headers or body, authors should response's headers or body, authors should point out that this has
point out that this has implications for caching; in general, such implications for caching; in general, such resources need to either
resources need to either make their responses uncacheable (e.g., with make their responses uncacheable (e.g., with the "no-store" cache-
the "no-store" cache-control directive defined in [RFC7234], control directive defined in [I-D.ietf-httpbis-cache],
Section 5.2.2.3) or consistently send the Vary response header Section 5.2.2.3) or send the Vary response header
([RFC7231], Section 7.1.4). ([I-D.ietf-httpbis-semantics], Section 10.1.4) on all responses from
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
[content] [content]
can be stored for 60 seconds by both private and shared caches, can can be stored for 60 seconds by both private and shared caches, can
be revalidated with If-None-Match, and varies on the Accept-Encoding be revalidated with If-None-Match, and varies on the Accept-Encoding
request header field. request header field.
In some situations, responses without explicit cache directives In some situations, responses without explicit cache directives
(e.g., Cache-Control or Expires) will be stored and served using a (e.g., Cache-Control or Expires) will be stored and served using a
heuristic freshness lifetime; see [RFC7234], Section 4.2.2. As the heuristic freshness lifetime; see [I-D.ietf-httpbis-cache],
heuristic is not under control of the application, it is generally Section 4.2.2. As the heuristic is not under control of the
preferable to set an explicit freshness lifetime. application, it is generally preferable to set an explicit freshness
lifetime.
If caching of a response is not desired, the appropriate response If caching of a response is not desired, the appropriate response
directive is "Cache-Control: no-store". This only need be sent in directive is "Cache-Control: no-store". This only need be sent in
situations where the response might be cached; see [RFC7234], situations where the response might be cached; see
Section 3. Note that "Cache-Control: no-cache" allows a response to [I-D.ietf-httpbis-cache], Section 3. Note that "Cache-Control: no-
be stored, just not reused by a cache; it does not prevent caching cache" allows a response to be stored, just not reused by a cache; it
(despite its name). does not prevent caching (despite its name).
For example, this response cannot be stored or reused by a cache: For example, this response cannot be stored or reused by a cache:
HTTP/1.1 200 OK HTTP/1.1 200 OK
Content-Type: application/example+xml Content-Type: application/example+xml
Cache-Control: no-store Cache-Control: no-store
[content] [content]
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 expressed separately, from the freshness lifetime, this should be expressed separately,
either in the response's body or in a separate header field. When either in the response's body 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.
Like other functions, HTTP caching is generic; it does not have Like other functions, HTTP caching is generic; it does not have
knowledge of the application in use. Therefore, caching extensions knowledge of the application in use. Therefore, caching extensions
need to be backwards-compatible, as per [RFC7234], Section 5.2.3. need to be backwards-compatible, as per [I-D.ietf-httpbis-cache],
Section 5.2.3.
4.10. Application State 4.10. Application State
Applications that use HTTP MAY use stateful cookies [RFC6265] to Applications MAY use stateful cookies [I-D.ietf-httpbis-rfc6265bis]
identify a client and/or store client-specific data to contextualise to identify a client and/or store client-specific data to
requests. contextualise requests.
When used, it is important to carefully specify the scoping and use When used, it is important to carefully specify the scoping and use
of cookies; if the application exposes sensitive data or capabilities of cookies; if the application exposes sensitive data or capabilities
(e.g., by acting as an ambient authority), exploits are possible. (e.g., by acting as an ambient authority), exploits are possible.
Mitigations include using a request-specific token to assure the Mitigations include using a request-specific token to assure the
intent of the client. intent of the client.
Applications MUST NOT make assumptions about the relationship between Applications MUST NOT make assumptions about the relationship between
separate requests on a single transport connection; doing so breaks separate requests on a single transport connection; doing so breaks
many of the assumptions of HTTP as a stateless protocol, and will many of the assumptions of HTTP as a stateless protocol, and will
cause problems in interoperability, security, operability and cause problems in interoperability, security, operability and
evolution. evolution.
4.11. Client Authentication 4.11. Client Authentication
Applications that use HTTP MAY use HTTP authentication [RFC7235] to Applications MAY use HTTP authentication [I-D.ietf-httpbis-semantics]
identify clients. The Basic authentication scheme [RFC7617] MUST NOT to identify clients. The Basic authentication scheme [RFC7617] MUST
be used unless the underlying transport is authenticated, integrity- NOT be used unless the underlying transport is authenticated,
protected and confidential (e.g., as provided the "HTTPS" URL scheme, integrity-protected and confidential (e.g., as provided the "HTTPS"
or another using TLS). The Digest scheme [RFC7616] MUST NOT be used URL scheme, or another using TLS). The Digest scheme [RFC7616] MUST
unless the underlying transport is similarly secure, or the chosen NOT be used unless the underlying transport is similarly secure, or
hash algorithm is not "MD5". the chosen hash algorithm is not "MD5".
With HTTPS, clients might also be authenticated using certificates With HTTPS, clients might also be authenticated using certificates
[RFC5246]. [RFC5246].
When used, it is important to carefully specify the scoping and use When used, it is important to carefully specify the scoping and use
of authentication; if the application exposes sensitive data or of authentication; if the application exposes sensitive data or
capabilities (e.g., by acting as an ambient authority), exploits are capabilities (e.g., by acting as an ambient authority), exploits are
possible. Mitigations include using a request-specific token to possible. Mitigations include using a request-specific token to
assure the intent of the client. assure the intent of the client.
4.12. Co-Existing with Web Browsing 4.12. Co-Existing with Web Browsing
Even if there is not an intent for an application that uses HTTP to Even if there is not an intent for an application to be used with a
be used with a Web browser, its resources will remain available to Web browser, its resources will remain available to browsers and
browsers and other HTTP clients. other HTTP clients.
This means that all such applications need to consider how browsers This means that all such applications that use HTTP need to consider
will interact with them, particularly regarding security. how browsers will interact with them, particularly regarding
security.
For example, if an application's state can be changed using a POST For example, if an application's state can be changed using a POST
request, a Web browser can easily be coaxed into cross-site request request, a Web browser can easily be coaxed into cross-site request
forgery (CSRF) from arbitrary Web sites. forgery (CSRF) from arbitrary Web sites.
Or, If content returned from the application's resources is under Or, if content returned from the application's resources is under
control of an attacker (for example, part of the request is reflected control of an attacker (for example, part of the request is reflected
in the response, or the response contains external information that in the response, or the response contains external information that
might be under the control of the attacker), a cross-site scripting might be under the control of the attacker), a cross-site scripting
(XSS) attack is possible, whereby an attacker can inject code into (XSS) attack is possible, whereby an attacker can inject code into
the browser and access data and capabilities on that origin. the browser and access data and capabilities on that origin.
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.
skipping to change at page 22, line 9 skipping to change at page 22, line 20
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 [HTML5]), thereby mitigating of active content (such as HTML [HTML5]), thereby mitigating
Cross-Site Scripting attacks Cross-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
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 [RFC6265] not exposed to browser scripting languages
[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
information. information
Depending on how they are intended to be deployed, specifications for Depending on how they are intended to be deployed, specifications for
applications using HTTP might require the use of these mechanisms in applications using HTTP might require the use of these mechanisms in
specific ways, or might merely point them out in Security specific ways, or might merely point them out in Security
Considerations. Considerations.
An example of a HTTP response from an application that does not An example of a HTTP response from an application that does not
intend for its content to be treated as active by browsers might look intend for its content to be treated as active by browsers might look
like this: like this:
HTTP/1.1 200 OK HTTP/1.1 200 OK
Content-Type: application/example+json Content-Type: application/example+json
X-Content-Type-Options: nosniff X-Content-Type-Options: nosniff
Content-Security-Policy: default-src 'none' Content-Security-Policy: default-src 'none'
Cache-Control: max-age=3600 Cache-Control: max-age=3600
Referrer-Policy: no-referrer Referrer-Policy: no-referrer
[content] [content]
If an application using HTTP has browser compatibility as a goal, If an application has browser compatibility as a goal, client
client interaction ought to be defined in terms of [FETCH], since interaction ought to be defined in terms of [FETCH], since that is
that is the abstraction that browsers use for HTTP; it enforces many the abstraction that browsers use for HTTP; it enforces many of these
of these best practices. best practices.
4.13. Application Boundaries 4.13. Application Boundaries
Because the origin [RFC6454] is how many HTTP capabilities are Because the origin [RFC6454] is how many HTTP capabilities are
scoped, applications also need to consider how deployments might scoped, applications also need to consider how deployments might
interact with other applications (including Web browsing) on the same interact with other applications (including Web browsing) on the same
origin. origin.
For example, if Cookies [RFC6265] are used to carry application For example, if Cookies [I-D.ietf-httpbis-rfc6265bis] are used to
state, they will be sent with all requests to the origin by default, carry application state, they will be sent with all requests to the
unless scoped by path, and the application might receive cookies from origin by default, unless scoped by path, and the application might
other applications on the origin. This can lead to security issues, receive cookies from other applications on the origin. This can lead
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 [RFC7320] 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 [RFC7235], or other origin-wide HTTP authentication realms [I-D.ietf-httpbis-semantics], or other origin-
mechanisms, applications using HTTP SHOULD NOT mandate the use of a wide HTTP mechanisms, applications using HTTP SHOULD NOT mandate the
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. Server Push 4.14. Server Push
skipping to change at page 26, line 11 skipping to change at page 26, line 30
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 avoid a unique identifier for the system. Applications are advised avoid
allowing the use of mobile code where possible; when it cannot be allowing the use of mobile code where possible; when it cannot be
avoided, the resulting system's security properties need be carefully avoided, the resulting system's security properties need be carefully
scrutinised. scrutinised.
7. References 7. References
7.1. Normative References 7.1. Normative References
[I-D.ietf-httpbis-cache]
Fielding, R., Nottingham, M., and J. Reschke, "HTTP
Caching", draft-ietf-httpbis-cache-03 (work in progress),
October 2018.
[I-D.ietf-httpbis-messaging]
Fielding, R., Nottingham, M., and J. Reschke, "HTTP/1.1
Messaging", draft-ietf-httpbis-messaging-03 (work in
progress), October 2018.
[I-D.ietf-httpbis-semantics]
Fielding, R., Nottingham, M., and J. Reschke, "HTTP
Semantics", draft-ietf-httpbis-semantics-03 (work in
progress), October 2018.
[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, [RFC2818] Rescorla, E., "HTTP Over TLS", RFC 2818,
DOI 10.17487/RFC2818, May 2000, DOI 10.17487/RFC2818, May 2000,
<https://www.rfc-editor.org/info/rfc2818>. <https://www.rfc-editor.org/info/rfc2818>.
[RFC3864] Klyne, G., Nottingham, M., and J. Mogul, "Registration
Procedures for Message Header Fields", BCP 90, RFC 3864,
DOI 10.17487/RFC3864, September 2004,
<https://www.rfc-editor.org/info/rfc3864>.
[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,
"Deprecating the "X-" Prefix and Similar Constructs in "Deprecating the "X-" Prefix and Similar Constructs in
Application Protocols", BCP 178, RFC 6648, Application Protocols", BCP 178, RFC 6648,
DOI 10.17487/RFC6648, June 2012, DOI 10.17487/RFC6648, June 2012,
<https://www.rfc-editor.org/info/rfc6648>. <https://www.rfc-editor.org/info/rfc6648>.
[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>.
[RFC7230] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer
Protocol (HTTP/1.1): Message Syntax and Routing",
RFC 7230, DOI 10.17487/RFC7230, June 2014,
<https://www.rfc-editor.org/info/rfc7230>.
[RFC7231] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer
Protocol (HTTP/1.1): Semantics and Content", RFC 7231,
DOI 10.17487/RFC7231, June 2014,
<https://www.rfc-editor.org/info/rfc7231>.
[RFC7232] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer
Protocol (HTTP/1.1): Conditional Requests", RFC 7232,
DOI 10.17487/RFC7232, June 2014,
<https://www.rfc-editor.org/info/rfc7232>.
[RFC7233] Fielding, R., Ed., Lafon, Y., Ed., and J. Reschke, Ed.,
"Hypertext Transfer Protocol (HTTP/1.1): Range Requests",
RFC 7233, DOI 10.17487/RFC7233, June 2014,
<https://www.rfc-editor.org/info/rfc7233>.
[RFC7234] Fielding, R., Ed., Nottingham, M., Ed., and J. Reschke,
Ed., "Hypertext Transfer Protocol (HTTP/1.1): Caching",
RFC 7234, DOI 10.17487/RFC7234, June 2014,
<https://www.rfc-editor.org/info/rfc7234>.
[RFC7235] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer
Protocol (HTTP/1.1): Authentication", RFC 7235,
DOI 10.17487/RFC7235, June 2014,
<https://www.rfc-editor.org/info/rfc7235>.
[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, [RFC7320] Nottingham, M., "URI Design and Ownership", BCP 190,
RFC 7320, DOI 10.17487/RFC7320, July 2014, RFC 7320, DOI 10.17487/RFC7320, July 2014,
<https://www.rfc-editor.org/info/rfc7320>. <https://www.rfc-editor.org/info/rfc7320>.
[RFC7540] Belshe, M., Peon, R., and M. Thomson, Ed., "Hypertext [RFC7540] Belshe, M., Peon, R., and M. Thomson, Ed., "Hypertext
skipping to change at page 28, line 16 skipping to change at page 28, line 10
<https://fetch.spec.whatwg.org>. <https://fetch.spec.whatwg.org>.
[HTML5] WHATWG, "HTML - Living Standard", n.d., [HTML5] WHATWG, "HTML - Living Standard", n.d.,
<https://html.spec.whatwg.org>. <https://html.spec.whatwg.org>.
[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 Headers for HTTP",
draft-ietf-httpbis-header-structure-07 (work in progress), draft-ietf-httpbis-header-structure-07 (work in progress),
July 2018. July 2018.
[I-D.ietf-httpbis-rfc6265bis]
Barth, A. and M. West, "Cookies: HTTP State Management
Mechanism", draft-ietf-httpbis-rfc6265bis-02 (work in
progress), August 2017.
[I-D.nottingham-rfc5785bis]
Nottingham, M., "Well-Known Uniform Resource Identifiers
(URIs)", draft-nottingham-rfc5785bis-08 (work in
progress), October 2018.
[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 28, line 46 skipping to change at page 28, line 50
[RFC4918] Dusseault, L., Ed., "HTTP Extensions for Web Distributed [RFC4918] Dusseault, L., Ed., "HTTP Extensions for Web Distributed
Authoring and Versioning (WebDAV)", RFC 4918, Authoring and Versioning (WebDAV)", RFC 4918,
DOI 10.17487/RFC4918, June 2007, DOI 10.17487/RFC4918, June 2007,
<https://www.rfc-editor.org/info/rfc4918>. <https://www.rfc-editor.org/info/rfc4918>.
[RFC5246] Dierks, T. and E. Rescorla, "The Transport Layer Security [RFC5246] Dierks, T. and E. Rescorla, "The Transport Layer Security
(TLS) Protocol Version 1.2", RFC 5246, (TLS) Protocol Version 1.2", RFC 5246,
DOI 10.17487/RFC5246, August 2008, DOI 10.17487/RFC5246, August 2008,
<https://www.rfc-editor.org/info/rfc5246>. <https://www.rfc-editor.org/info/rfc5246>.
[RFC5785] Nottingham, M. and E. Hammer-Lahav, "Defining Well-Known
Uniform Resource Identifiers (URIs)", RFC 5785,
DOI 10.17487/RFC5785, April 2010,
<https://www.rfc-editor.org/info/rfc5785>.
[RFC5861] Nottingham, M., "HTTP Cache-Control Extensions for Stale [RFC5861] Nottingham, M., "HTTP Cache-Control Extensions for Stale
Content", RFC 5861, DOI 10.17487/RFC5861, May 2010, Content", RFC 5861, DOI 10.17487/RFC5861, May 2010,
<https://www.rfc-editor.org/info/rfc5861>. <https://www.rfc-editor.org/info/rfc5861>.
[RFC6265] Barth, A., "HTTP State Management Mechanism", RFC 6265,
DOI 10.17487/RFC6265, April 2011,
<https://www.rfc-editor.org/info/rfc6265>.
[RFC6415] Hammer-Lahav, E., Ed. and B. Cook, "Web Host Metadata", [RFC6415] Hammer-Lahav, E., Ed. and B. Cook, "Web Host Metadata",
RFC 6415, DOI 10.17487/RFC6415, October 2011, RFC 6415, DOI 10.17487/RFC6415, October 2011,
<https://www.rfc-editor.org/info/rfc6415>. <https://www.rfc-editor.org/info/rfc6415>.
[RFC6797] Hodges, J., Jackson, C., and A. Barth, "HTTP Strict [RFC6797] Hodges, J., Jackson, C., and A. Barth, "HTTP Strict
Transport Security (HSTS)", RFC 6797, Transport Security (HSTS)", RFC 6797,
DOI 10.17487/RFC6797, November 2012, DOI 10.17487/RFC6797, November 2012,
<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
 End of changes. 67 change blocks. 
240 lines changed or deleted 235 lines changed or added

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