<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE rfc [
  <!ENTITY nbsp    "&#160;">
  <!ENTITY zwsp   "&#8203;">
  <!ENTITY nbhy   "&#8209;">
  <!ENTITY wj     "&#8288;">
]>

<rfc xmlns:xi="http://www.w3.org/2001/XInclude" ipr="trust200902" docName="draft-ietf-httpbis-bcp56bis-15" number="9205" obsoletes="3205" updates="" submissionType="IETF" category="bcp" consensus="true" xml:lang="en" symRefs="true" sortRefs="true" tocInclude="true" version="3">

  <front>
    <title>Building Protocols with HTTP</title>
    <seriesInfo name="RFC" value="9205"/>
    <seriesInfo name="BCP" value="56"/>
    <author initials="M." surname="Nottingham" fullname="Mark Nottingham">
      <organization/>
      <address>
        <postal>
          <postalLine>Prahran</postalLine>
          <postalLine>Australia</postalLine>
        </postal>
        <email>mnot@mnot.net</email>
        <uri>https://www.mnot.net/</uri>
      </address>
    </author>
    <date year="2022" month="June" />
    <area>Applications and Real-Time</area>
    <workgroup>HTTP</workgroup>
    <keyword>HTTP API</keyword>
    <abstract>
      <t>Applications often use HTTP as a substrate to create HTTP-based APIs. This document specifies best practices for writing specifications that use HTTP to define new application protocols. It is written primarily to guide IETF efforts to define application protocols using HTTP for deployment on the Internet but might be applicable in other situations.</t>
      <t>This document obsoletes RFC 3205.</t>
    </abstract>
  </front>
  <middle>
    <section anchor="introduction" numbered="true" toc="default">
      <name>Introduction</name>
      <t>Applications other than Web browsing often use HTTP <xref target="HTTP" format="default"/> as a substrate, a practice sometimes referred to as creating "HTTP-based APIs", "REST APIs", or just "HTTP APIs". This is done for a variety of reasons, including:</t>
      <ul spacing="normal">
        <li>familiarity by implementers, specifiers, administrators, developers, and users;</li>
        <li>availability of a variety of client, server, and proxy implementations;</li>
        <li>ease of use;</li>
        <li>availability of Web browsers;</li>
        <li>reuse of existing mechanisms like authentication and encryption;</li>
        <li>presence of HTTP servers and clients in target deployments; and</li>
        <li>its ability to traverse firewalls.</li>
      </ul>
      <t>These protocols are often ad hoc, intended for only 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 around defining HTTP-based APIs that favour these conditions.</t>
      <t>However, when such an application has multiple, separate implementations, is deployed on multiple uncoordinated servers, and is consumed by diverse clients (as is often the case for HTTP APIs defined by standards efforts), tools and practices intended for limited deployment can become unsuitable.</t>
      <t>This mismatch is largely because the API's clients and servers will implement and evolve at different paces, leading to a need for deployments with different features and versions to coexist. As a result, the designers of HTTP-based APIs intended for such deployments need to more carefully consider how extensibility of the service will be handled and how different deployment requirements will be accommodated.</t>
      <t>More generally, an application protocol using HTTP faces a number of design decisions, including:</t>
      <ul spacing="normal">
        <li>Should it define a new URI scheme? Use new ports?</li>
        <li>Should it use standard HTTP methods and status codes or define new ones?</li>
        <li>How can the maximum value be extracted from the use of HTTP?</li>
        <li>How does it coexist with other uses of HTTP -- especially Web browsing?</li>
        <li>How can interoperability problems and "protocol dead ends" be avoided?</li>
      </ul>
      <t><xref target="used" format="default"/> defines when this document applies, <xref target="overview" format="default"/> surveys the properties of HTTP that are important to preserve, and <xref target="bp" format="default"/> contains best practices for the specification of applications that use HTTP.</t>
      <t>It is written primarily to guide IETF efforts to define application protocols using HTTP for deployment on the Internet but might be applicable in other situations. Note that the requirements herein do not necessarily apply to the development of generic HTTP extensions.</t>
      <t>This document obsoletes <xref target="RFC3205" format="default"/> to reflect the experience and developments regarding HTTP in the intervening time.</t>
      <section anchor="notational-conventions" numbered="true" toc="default">
        <name>Notational Conventions</name>
        <t>
    The key words "<bcp14>MUST</bcp14>", "<bcp14>MUST NOT</bcp14>", "<bcp14>REQUIRED</bcp14>", "<bcp14>SHALL</bcp14>", "<bcp14>SHALL
    NOT</bcp14>", "<bcp14>SHOULD</bcp14>", "<bcp14>SHOULD NOT</bcp14>", "<bcp14>RECOMMENDED</bcp14>", "<bcp14>NOT RECOMMENDED</bcp14>",
    "<bcp14>MAY</bcp14>", and "<bcp14>OPTIONAL</bcp14>" in this document are to be interpreted as
    described in BCP&nbsp;14 <xref target="RFC2119"/> <xref target="RFC8174"/> 
    when, and only when, they appear in all capitals, as shown here.
        </t>
      </section>
    </section>
    <section anchor="used" numbered="true" toc="default">
      <name>Is HTTP Being Used?</name>
      <t>Different applications have different goals when using HTTP. The recommendations in this document apply when a specification defines an application that:</t>
      <ul spacing="normal">
        <li>uses the transport port 80 or 443, or</li>
        <li>uses the URI scheme "http" or "https", or</li>
        <li>uses an ALPN protocol ID <xref target="RFC7301" format="default"/> that generically identifies HTTP (e.g., "http/1.1", "h2", "h3"), or</li>
        <li>makes registrations in or overall modifications to the IANA registries defined for HTTP.</li>
      </ul>
      <t>Additionally, when a specification is using HTTP, all of the requirements of the HTTP protocol suite are in force (<xref target="HTTP" format="default"/> in particular but also other specifications such as the specific version of HTTP in use and any extensions in use).</t>
      <t>Note that this document is intended to apply to applications, not generic extensions to HTTP. Furthermore, while it is intended for IETF-specified applications, other standards organisations are encouraged to adhere to its requirements.</t>
      <section anchor="non-http-protocols" numbered="true" toc="default">
        <name>Non-HTTP Protocols</name>
        <t>An application can rely upon HTTP without meeting the criteria for using it as defined above.
	For example, an application might wish to avoid re-specifying parts of the message format but might change other aspects of the protocol's operation, or it might want to use application-specific methods.</t>
        <t>Doing so permits more freedom to modify protocol operations, but at least a portion of the benefits outlined in <xref target="overview" format="default"/> are lost as most HTTP implementations won't be easily adaptable to these changes. The benefit of mindshare will also be lost.</t>
        <t>Such specifications <bcp14>MUST NOT</bcp14> use HTTP's URI schemes, transport ports, ALPN protocol IDs, or IANA registries; rather, they are encouraged to establish their own.</t>
      </section>
    </section>
    <section anchor="overview" numbered="true" toc="default">
      <name>What's Important About HTTP</name>
      <t>This section examines the characteristics of HTTP that are important to consider when using HTTP to define an application protocol.</t>
      <section anchor="generic-semantics" numbered="true" toc="default">
        <name>Generic Semantics</name>
<t>Much of the value of HTTP is in its generic semantics -- that is, the protocol elements defined by HTTP are potentially applicable to every resource and are not specific to a particular context. Application-specific semantics are best expressed in message content and header fields, not status codes or methods (although status codes and methods do have generic semantics that relate to application state).</t>
        <t>This split between generic and application-specific semantics allows an HTTP message to be handled by common software (e.g., HTTP servers, intermediaries, client implementations, and caches) without requiring those implementations to understand the application in use. It also allows people to leverage their knowledge of HTTP semantics without needing specialised knowledge of a particular application.</t>
        <t>Therefore, applications that use HTTP <bcp14>MUST NOT</bcp14> redefine, refine, or overlay the semantics of generic protocol elements such as methods, status codes, or existing header fields. Instead, they should focus their specifications on protocol elements that are specific to that application -- namely, their HTTP resources.</t>
        <t>When writing a specification, it's often tempting to specify exactly how HTTP is to be implemented, supported, and used. However, this can easily lead to an unintended profile of HTTP behaviour. For example, it's common to see specifications with language like this:</t>
        <blockquote>
        <t>A POST request MUST result in a 201 (Created) response.</t>
        </blockquote>
        <t>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 status code might differ in a real deployment; for example, there might be a proxy that requires authentication, or a server-side error, or a redirection. If the client does not anticipate this, the application's deployment is brittle.</t>
        <t>See <xref target="resource" format="default"/> for more details.</t>
      </section>
      <section anchor="links" numbered="true" toc="default">
        <name>Links</name>
        <t>Another common practice is assuming that the HTTP server's namespace (or a portion thereof) is exclusively for the use of a single application. This effectively overlays special, application-specific semantics onto that space and precludes other applications from using it.</t>
        <t>As explained in <xref target="BCP190" format="default"/>, such "squatting" on a part of the URL space by a standard usurps the server's authority over its own resources, can cause deployment issues, and is therefore bad practice in standards.</t>
        <t>Instead of statically defining URI components like paths, it is <bcp14>RECOMMENDED</bcp14> that applications using HTTP define and use links <xref target="WEB-LINKING" format="default"/> to allow flexibility in deployment.</t>
        <t>Using runtime links in this fashion has a number of other benefits -- especially when an application is to have multiple implementations and/or deployments (as is often the case for those that are standardised).</t>
        <t>For example, navigating with a link allows a request to be routed to a different server without the overhead of a redirection, thereby supporting deployment across machines well.</t>
        <t>By using links, it also becomes possible to "mix and match" different applications on the same server. The use of links also offers a natural mechanism for extensibility, versioning, and capability management because the document containing the links can also contain information about their targets.</t>
        <t>Using links also offers a form of cache invalidation that's seen on the Web; when a resource's state changes, the application can change the affected links so that a fresh copy is always fetched.</t>
        <t>See <xref target="specifying-urls" format="default"/> for more details.</t>
      </section>
      <section anchor="rich-functionality" numbered="true" toc="default">
        <name>Rich Functionality</name>
        <t>HTTP offers a number of features to applications, such as:</t>
        <ul spacing="normal">
          <li>Message framing</li>
          <li>Multiplexing (in HTTP/2 <xref target="HTTP2" format="default"/> and HTTP/3 <xref target="HTTP3" format="default"/>)</li>
          <li>Integration with TLS</li>
          <li>Support for intermediaries (proxies, gateways, content delivery networks (CDNs))</li>
          <li>Client authentication</li>
          <li>Content negotiation for format, language, and other features</li>
          <li>Caching for server scalability, latency and bandwidth reduction, and reliability</li>
          <li>Granularity of access control (through use of a rich space of URLs)</li>
          <li>Partial content to selectively request part of a response</li>
          <li>The ability to interact with the application easily using a Web browser</li>
        </ul>
        <t>An application that uses HTTP is encouraged to utilise the various features that the protocol offers so that its users receive the maximum benefit from those features and so that the application can be deployed in a variety of situations. This document does not require specific features to be used since the appropriate design trade-offs are highly specific to a given situation. However, following the practices in <xref target="bp" format="default"/> is a good starting point.</t>
      </section>
    </section>
    <section anchor="bp" numbered="true" toc="default">
      <name>Best Practices for Specifying the Use of HTTP</name>
      <t>This section contains best practices for specifying the use of HTTP by applications, including practices for specific HTTP protocol elements.</t>
      <section anchor="specifying-the-use-of-http" numbered="true" toc="default">
        <name>Specifying the Use of HTTP</name>
        <t>Specifications should use <xref target="HTTP" format="default"/> as the primary reference for HTTP; it is not necessary to reference all of the specifications in the HTTP suite unless there are specific reasons to do so (e.g., a particular feature is called out).</t>
        <t>Because HTTP is a hop-by-hop protocol, a connection can be handled by implementations that are not controlled by the application; for example, proxies, CDNs, firewalls, and so on. Requiring a particular version of HTTP makes it difficult to use in these situations and harms interoperability. Therefore, it is <bcp14>NOT RECOMMENDED</bcp14> that applications using HTTP specify a minimum version of HTTP to be used.</t>
        <t>However, if an application's deployment benefits from the use of a particular version of HTTP (for example, HTTP/2's multiplexing), this ought be noted.</t>
        <t>Applications using HTTP <bcp14>MUST NOT</bcp14> specify a maximum version, to preserve the protocol's ability to evolve.</t>
        <t>When specifying examples of protocol interactions, applications should document both the request and response messages with complete header sections, preferably in HTTP/1.1 format <xref target="HTTP11" format="default"/>. For example:</t>
        <sourcecode type="http-message"><![CDATA[
GET /thing HTTP/1.1
Host: example.com
Accept: application/things+json
User-Agent: Foo/1.0

]]></sourcecode>
        <sourcecode type="http-message"><![CDATA[
HTTP/1.1 200 OK
Content-Type: application/things+json
Content-Length: 500
Server: Bar/2.2

[content here]
]]></sourcecode>
      </section>
      <section anchor="resource" numbered="true" toc="default">
        <name>Specifying Server Behaviour</name>
        <t>The server-side behaviours of an application are most effectively specified by defining the following protocol elements:</t>
        <ul spacing="normal">
          <li>Media types <xref target="RFC6838" format="default"/>, often based upon a format convention such as JSON <xref target="JSON" format="default"/>;</li>
          <li>HTTP header fields, per <xref target="headers" format="default"/>; and</li>
          <li>The behaviour of resources, as identified by link relations <xref target="WEB-LINKING" format="default"/>.</li>
        </ul>
        <t>An application can define its operation by composing these protocol elements to define a set of resources that are identified by link relations and that implement specified behaviours, including:</t>
        <ul spacing="normal">
          <li>retrieval of resource state using GET in one or more formats identified by media type;</li>
          <li>resource creation or update using POST or PUT, with an appropriately identified request content format;</li>
          <li>data processing using POST and identified request and response content format(s); and</li>
          <li>Resource deletion using DELETE.</li>
        </ul>
        <t>For example, an application might specify:</t>
        <blockquote>
<t>Resources linked to with the "example-widget" link relation type are
Widgets. The state of a Widget can be fetched in the
"application/example-widget+json" format, and can be updated by PUT
to the same link. Widget resources can be deleted.</t>

<t>The Example-Count response header field on Widget representations
indicates how many Widgets are held by the sender.</t>

<t>The "application/example-widget+json" format is a JSON [RFC8259]
format representing the state of a Widget. It contains links to
related information in the link indicated by the Link header field
value with the "example-other-info" link relation type.</t>
        </blockquote>
        <t>Applications can also specify the use of URI Templates <xref target="URI-TEMPLATE" format="default"/> to allow clients to generate URLs based upon runtime data.</t>
      </section>
      <section anchor="clients" numbered="true" toc="default">
        <name>Specifying Client Behaviour</name>
        <t>An application's expectations for client behaviour ought to be closely aligned with those of Web browsers to avoid interoperability issues when they are used.</t>
        <t>One way to do this is to define it in terms of <xref target="FETCH" format="default"/> since that is the abstraction that browsers use for HTTP.</t>
        <t>Some client behaviours (e.g., automatic redirect handling) and extensions (e.g., cookies) are not required by HTTP but nevertheless have become very common. If their use is not explicitly specified by applications using HTTP, there may be confusion and interoperability problems. In particular:</t>
        <dl spacing="normal">
          <dt>Redirect handling:</dt><dd>Applications need to specify how redirects are expected to be handled; see <xref target="redirects" format="default"/>.</dd>
          <dt>Cookies:</dt><dd>Applications using HTTP should explicitly reference the Cookie specification <xref target="COOKIES" format="default"/> if they are required.</dd>
          <dt>Certificates:</dt><dd>Applications using HTTP should specify that TLS certificates are to be checked according to <xref section="4.3.4" sectionFormat="of" target="HTTP" format="default"/> when HTTPS is used.</dd>
        </dl>
        <t>Applications using HTTP should not require that clients statically support HTTP features that are usually negotiated. For example, requiring that clients support responses with a certain content coding (<xref section="8.4.1" sectionFormat="comma" target="HTTP" format="default"/>) instead of negotiating for it (<xref section="12.5.3" sectionFormat="comma" target="HTTP" format="default"/>) means that otherwise conformant clients cannot interoperate with the application. Applications can encourage the implementation of such features, though.</t>
      </section>
      <section anchor="specifying-urls" numbered="true" toc="default">
        <name>Specifying URLs</name>
        <t>In HTTP, the resources that clients interact with are identified with URLs <xref target="URL" format="default"/>. As <xref target="BCP190" format="default"/> explains, parts of the 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 deployment.</t>
        <t>This means that in most cases, specifications for applications that use HTTP won't contain fixed application URLs or paths; while it is common practice for a specification of a single-deployment API to specify the path prefix "/app/v1" (for example), doing so in an IETF specification is inappropriate.</t>
        <t>Therefore, the specification writer needs some mechanism to allow clients to discover an application's URLs. Additionally, they need to specify which URL scheme(s) the application should be used with and whether to use a dedicated port or to reuse HTTP's port(s).</t>
        <section anchor="discovering-an-applications-urls" numbered="true" toc="default">
          <name>Discovering an Application's URLs</name>
          <t>Generally, a client will begin interacting with a given application server by requesting an initial document that contains information about that particular deployment, potentially including links to other relevant resources. Doing so ensures that the deployment is as flexible as possible (potentially spanning multiple servers), allows evolution, and also gives the application the opportunity to tailor the "discovery document" to the client.</t>
          <t>There are a few common patterns for discovering that initial URL.</t>
          <t>The most straightforward mechanism for URL discovery is to configure the client with (or otherwise convey to it) a full URL. This might be done in a configuration document or through another discovery mechanism.</t>
          <t>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 initial URL from that information.</t>
          <t>An application cannot define a fixed prefix for its URL paths; see <xref target="BCP190" format="default"/>. Instead, a specification for such an application can use one of the following strategies:</t>
          <ul spacing="normal">
            <li>Register a well-known URI <xref target="WELL-KNOWN-URI" format="default"/> as an entry point for that application. This provides a fixed path on every potential server that will not collide with other applications.</li>
            <li>Enable the server authority to convey a URI Template <xref target="URI-TEMPLATE" format="default"/> or similar mechanism for generating a URL for an entry point. For example, this might be done in a configuration document or other artefact.</li>
          </ul>
          <t>Once the discovery document is located, it can be fetched, cached for later reuse (if allowed by its metadata), and used to locate other resources that are relevant to the application using full URIs or URL Templates.</t>
          <t>In some cases, an application may not wish to use such a discovery document -- for example, when communication is very brief or when the latency concerns of doing so preclude the use of a discovery document. These situations can be addressed by placing all of the application's resources under a well-known location.</t>
        </section>
        <section anchor="scheme" numbered="true" toc="default">
          <name>Considering URI Schemes</name>
          <t>Applications that use HTTP will typically employ the "http" and/or "https" URI schemes. "https" is <bcp14>RECOMMENDED</bcp14> to provide authentication, integrity, and confidentiality, as well as to mitigate pervasive monitoring attacks <xref target="RFC7258" format="default"/>.</t>
          <t>However, application-specific schemes can also be defined. When defining a URI scheme for an application using HTTP, there are a number of trade-offs and caveats to keep in mind:</t>
          <ul spacing="normal">
            <li>Unmodified Web browsers will not support the new scheme. While it is possible to register new URI schemes with Web browsers (e.g., registerProtocolHandler() in <xref target="HTML" format="default"/>, as well as several proprietary approaches), support for these mechanisms is not shared by all browsers, and their capabilities vary.</li>
    <li>Existing non-browser clients, intermediaries, servers, and associated software will not recognise the new scheme.  For example, a client library might fail to dispatch the request, a cache might refuse to store the response, and a proxy might fail to forward the request.</li>
            <li>Because URLs commonly occur in HTTP artefacts and are often generated automatically (e.g., in the Location response header field), it can be difficult to ensure that the new scheme is used consistently.</li>
            <li>The resources identified by the new scheme will still be available using "http" and/or "https" URLs. Those URLs can "leak" into use, which can present security and operability issues. For example, using a new scheme to ensure that requests don't get sent to a "normal" Web site is likely to fail.</li>
            <li>Features that rely upon the URL's origin <xref target="RFC6454" format="default"/>, such as the Web's same-origin policy, will be impacted by a change of scheme.</li>
            <li>HTTP-specific features such as cookies <xref target="COOKIES" format="default"/>, authentication <xref target="HTTP" format="default"/>, caching <xref target="HTTP-CACHING" format="default"/>, HTTP Strict Transport Security (HSTS) <xref target="RFC6797" format="default"/>, and Cross-Origin Resource Sharing (CORS) <xref target="FETCH" format="default"/> might or might not work correctly, depending on how they are defined and implemented. Generally, they are designed and implemented with an assumption that the URL will always be "http" or "https".</li>
            <li>Web features that require a secure context <xref target="SECCTXT" format="default"/> will likely treat a new scheme as insecure.</li>
          </ul>
          <t>See <xref target="RFC7595" format="default"/> for more information about minting new URI schemes.</t>
        </section>
        <section anchor="choosing-transport-ports" numbered="true" toc="default">
          <name>Choosing Transport Ports</name>
          <t>Applications can use the applicable default port (80 for HTTP, 443 for HTTPS), or they can be deployed upon other ports. This decision can be made at deployment time or might be encouraged by the application's specification (e.g., by registering a port for that application).</t>
          <t>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 changing a default port is changing the URI scheme (see <xref target="scheme" format="default"/>).</t>
          <t>Using a port other than the default has privacy implications (i.e., the protocol can now be distinguished from other traffic), as well as operability concerns (as some networks might block or otherwise interfere with it). Privacy implications (including those stemming from this distinguishability) should be documented in Security Considerations.</t>
          <t>See <xref target="RFC7605" format="default"/> for further guidance.</t>
        </section>
      </section>
      <section anchor="using-http-methods" numbered="true" toc="default">
        <name>Using HTTP Methods</name>
        <t>Applications that use HTTP <bcp14>MUST</bcp14> confine themselves to using registered HTTP methods such as GET, POST, PUT, DELETE, and PATCH.</t>
        <t>New HTTP methods are rare; they are required to be registered in the "HTTP Method Registry" with IETF Review (see <xref target="HTTP" format="default"/>) and are also required to be generic. That means that they need to be potentially applicable to all resources, not just those of one application.</t>
        <t>While historically some applications (e.g., <xref target="RFC4791" format="default"/>) have defined application-specific methods, <xref target="HTTP" format="default"/> now forbids this.</t>
        <t>When authors believe that a new method is required, they are encouraged to engage with the HTTP community early (e.g., on the <eref target="mailto:ietf-http-wg@w3.org" brackets="angle"/> mailing list) and document their proposal as a separate HTTP extension rather than as part of an application's specification.</t>
        <section anchor="get" numbered="true" toc="default">
          <name>GET</name>
          <t>GET is the most common and useful HTTP method; its retrieval semantics allow caching and side-effect free linking and underlie many of the benefits of using HTTP.</t>
          <t>Queries can be performed with GET, often using the query component of the URL; this is a familiar pattern from Web browsing, and the results can be cached, improving the efficiency of an often expensive process. In some cases, however, GET might be unwieldy for expressing queries 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 to the URI syntax.</t>
          <t>While this is not an issue for short queries, it can become one for larger query terms or those that need to sustain a high rate of requests. Additionally, some HTTP implementations limit the size of URLs they support, although modern HTTP software has much more generous limits than previously (typically, considerably more than 8000 octets, as required by <xref target="HTTP" format="default"/>).</t>
         <t>In these cases, an application using HTTP might consider using POST to express queries in the request's content; doing so avoids encoding overhead and URL length limits in implementations. However, in doing so, it should be noted that the benefits of GET such as caching and linking to query results are lost.  Therefore, applications using HTTP that require support for POST queries ought to consider allowing both methods.</t>
          <t>Processing of GET requests should not change the application's state or have other side effects that might be significant to the client since implementations can and do retry HTTP GET requests that fail. Furthermore, some GET requests protected by TLS early data might be vulnerable to replay attacks (see <xref target="RFC8470" format="default"/>). Note that this does not include logging and similar functions; see <xref section="9.2.1" sectionFormat="comma" target="HTTP" format="default"/>.</t>
          <t>Finally, note that while the generic HTTP syntax allows a GET request message to contain content, the purpose is to allow message parsers to be generic; per <xref section="9.3.1" sectionFormat="comma" target="HTTP" format="default"/>, content in a GET is not recommended, has no meaning, and will be either ignored or rejected by generic HTTP software (such as intermediaries, caches, servers, and client libraries).</t>
        </section>
        <section anchor="options" numbered="true" toc="default">
          <name>OPTIONS</name>
          <t>The OPTIONS method was defined for metadata retrieval and is used both by Web Distributed Authoring and Versioning (WebDAV) <xref target="RFC4918" format="default"/> and CORS <xref target="FETCH" format="default"/>. Because HTTP-based APIs often need to retrieve metadata about resources, it is often considered for their use.</t>
          <t>However, OPTIONS does have significant limitations:</t>
          <ul spacing="normal">
            <li>It isn't possible to link to the metadata with a simple URL because OPTIONS is not the default method.</li>
            <li>OPTIONS responses are not cacheable because HTTP caches operate on representations of the resource (i.e., GET and HEAD). If OPTIONS responses are cached separately, their interactions with the HTTP cache expiry, secondary keys, and other mechanisms need to be considered.</li>
            <li>OPTIONS is "chatty" -- requesting metadata separately increases the number of requests needed to interact with the application.</li>
            <li>Implementation support for OPTIONS is not universal; some servers do not expose the ability to respond to OPTIONS requests without significant effort.</li>
          </ul>
          <t>Instead of OPTIONS, one of these alternative approaches might be more appropriate:</t>
          <ul spacing="normal">
            <li>For server-wide metadata, create a well-known URI <xref target="WELL-KNOWN-URI" format="default"/> or use an already existing one if appropriate (e.g., host-meta <xref target="RFC6415" format="default"/>).</li>
            <li>For metadata about a specific resource, create a separate resource and link to it using a Link response header field or a link serialised into the response's content. See <xref target="WEB-LINKING" format="default"/>. Note that the Link header field is available on HEAD responses, which is useful if the client wants to discover a resource's capabilities before they interact with it.</li>
          </ul>
        </section>
      </section>
      <section anchor="using-http-status-codes" numbered="true" toc="default">
        <name>Using HTTP Status Codes</name>
        <t>HTTP status codes convey semantics both for the benefit of generic HTTP components -- such as caches, intermediaries, and clients -- and applications themselves. However, applications can encounter a number of pitfalls in their use.</t>
        <t>First, status codes are often generated by components other than the application itself. This can happen, for example, when network errors are encountered; when a captive portal, proxy, or content delivery network is present; or when a server is overloaded or thinks it is under attack. They can even be generated by generic client software when certain error conditions are encountered. As a result, if an application assigns specific semantics to one of these status codes, a client can be misled about its state because the status code was generated by a generic component, not the application itself.</t>
        <t>Furthermore, mapping application errors to individual HTTP status 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 number of bad practices -- including minting new, application-specific status codes or using existing status codes even though the link between their semantics and the application's is tenuous at best.</t>
        <t>Instead, applications using HTTP should define their errors to use the most applicable status code, making generous use of the general status codes (200, 400, and 500) when in doubt. Importantly, they should not specify a one-to-one relationship between status codes and application errors, thereby avoiding the exhaustion issue outlined above.</t>
        <t>To distinguish between multiple error conditions that are mapped to the same status code and to avoid the misattribution issue outlined above, applications using HTTP should convey finer-grained error information in the response's message content and/or header fields. <xref target="PROBLEM-DETAILS" format="default"/> provides one way to do so.</t>
        <t>Because the set of registered HTTP status codes can expand, applications using HTTP should explicitly point out that clients ought to be able to handle all applicable status codes gracefully (i.e., falling back to the generic n00 semantics of a given status code; e.g., 499 can be safely handled as 400 (Bad Request) by clients that 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 foreseeable future.</t>
        <t>Applications using HTTP <bcp14>MUST NOT</bcp14> re-specify the semantics of HTTP status codes, even if it is only by copying their definition. It is <bcp14>NOT RECOMMENDED</bcp14> they require specific reason phrases to be used; the reason phrase has no function in HTTP, is not guaranteed to be preserved by implementations, and is not carried at all in the HTTP/2 <xref target="HTTP2" format="default"/> message format.</t>
        <t>Applications <bcp14>MUST</bcp14> only use registered HTTP status codes. As with methods, new HTTP status codes are rare and required (by <xref target="HTTP" format="default"/>) to be registered with IETF Review. Similarly, HTTP status codes are generic; they are required (by <xref target="HTTP" format="default"/>) to be potentially applicable to all resources, not just to those of one application.</t>
        <t>When authors believe that a new status code is required, they are encouraged to engage with the HTTP community early (e.g., on the <eref target="mailto:ietf-http-wg@w3.org" brackets="angle"/> mailing list) and document their proposal as a separate HTTP extension, rather than as part of an application's specification.</t>
        <section anchor="redirects" numbered="true" toc="default">
          <name>Redirection</name>
          <t>The 3xx series of status codes specified in <xref section="15.4" sectionFormat="of" target="HTTP" format="default"/> directs the user agent to another resource to satisfy the request. The most common of these are 301, 302, 307, and 308, all of which use the Location response header field to indicate where the client should resend the request.</t>
          <t>There are two ways that the members of this group of status codes differ:</t>
          <ul spacing="normal">
            <li>Whether they are permanent or temporary. Permanent redirects can be used to update links stored in the client (e.g., bookmarks), whereas temporary ones cannot. Note that this has no effect on HTTP caching; it is completely separate.</li>
            <li>Whether they allow the redirected request to change the request 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 redirection without changing the method.</li>
          </ul>
          <t>This table summarises their relationships:</t>
          <table align="center">
            <thead>
              <tr>
                <th align="left">&nbsp;</th>
                <th align="left">Permanent</th>
                <th align="left">Temporary</th>
              </tr>
            </thead>
            <tbody>
              <tr>
                <td align="left">Allows change of the request method from POST to GET</td>
                <td align="left">301</td>
                <td align="left">302</td>
              </tr>
              <tr>
                <td align="left">Does not allow change of the request method</td>
                <td align="left">308</td>
                <td align="left">307</td>
              </tr>
            </tbody>
          </table>
          <t>The 303 (See Other) status code can be used to inform the client that the result of an operation is available at a different location using GET.</t>
          <t>As noted in <xref target="HTTP" format="default"/>, a user agent is allowed to automatically follow a 3xx redirect that has a Location response header field, even if they don't understand the semantics of the specific status code. However, they aren't required to do so; therefore, if an application using HTTP desires redirects to be automatically followed, it needs to explicitly specify the circumstances when this is required.</t>
          <t>Redirects can be cached (when appropriate cache directives are present), but beyond that, they are not "sticky" -- i.e., redirection of a URI will not result in the client assuming that similar URIs (e.g., with different query parameters) will also be redirected.</t>
          <t>Applications using HTTP are encouraged to specify that 301 and 302 responses change the subsequent request method from POST (but no other method) to GET to be compatible with browsers.
Generally, when a redirected request is made, its header fields are copied from the original request. However, they can be modified by various mechanisms; e.g., sent Authorization (<xref section="11" sectionFormat="comma" target="HTTP" format="default"/>) and Cookie (<xref target="COOKIES" format="default"/>) header fields will change if the origin (and sometimes path) of the request changes. An application using HTTP should specify if any request header fields that it defines need to be modified or removed upon a redirect; however, this behaviour cannot be relied upon since a generic client (like a browser) will be unaware of such requirements.</t>
        </section>
      </section>
      <section anchor="headers" numbered="true" toc="default">
        <name>Specifying HTTP Header Fields</name>
        <t>Applications often define new HTTP header fields. Typically, using HTTP header fields is appropriate in a few different situations:</t>
        <ul spacing="normal">
          <li>The field is useful to intermediaries (who often wish to avoid parsing message content), and/or</li>
          <li>The field is useful to generic HTTP software (e.g., clients, servers), and/or</li>
          <li>It is not possible to include their values in the message content (usually because a format does not allow it).</li>
        </ul>
        <t>When the conditions above are not met, it is usually better to convey application-specific information in other places -- e.g., the message content or the URL query string.</t>
        <t>New header fields <bcp14>MUST</bcp14> be registered, per <xref section="16.3" sectionFormat="of" target="HTTP" format="default"/>.</t>
        <t>See <xref section="16.3.2" sectionFormat="of" target="HTTP" format="default"/> for guidelines to consider when minting new header fields. <xref target="STRUCTURED-FIELDS" format="default"/> provides a common structure for new header fields and avoids many issues in their parsing and handling; it is <bcp14>RECOMMENDED</bcp14> that new header fields use it.</t>
        <t>It is <bcp14>RECOMMENDED</bcp14> that header field names be short (even when field compression is used, there is an overhead) but appropriately specific. In particular, if a header field is specific to an application, an identifier for that application can form a prefix to the header field name, separated by a hyphen.</t>
        <t>For example, if the "example" application needs to create three header fields, they might be called "example-foo", "example-bar", and "example-baz". Note that the primary motivation here is to avoid consuming more generic field names, not to reserve a portion of the namespace for the application; see <xref target="RFC6648" format="default"/> for related considerations.</t>
        <t>The semantics of existing HTTP header fields <bcp14>MUST NOT</bcp14> be redefined without updating their registration or defining an extension to them (if allowed). For example, an application using HTTP cannot specify that the Location header field has a special meaning in a certain context.</t>
        <t>See <xref target="caching" format="default"/> for the interaction between header fields and HTTP caching; in particular, request header fields that are used to choose (per <xref section="4.1" sectionFormat="of" target="HTTP-CACHING" format="default"/>) a response have impact there and need to be carefully considered.</t>
        <t>See <xref target="state" format="default"/> for considerations regarding header fields that carry application state (e.g., Cookie).</t>
      </section>
      <section anchor="content" numbered="true" toc="default">
        <name>Defining Message Content</name>
        <t>Common syntactic conventions for message contents include JSON <xref target="JSON" format="default"/>, XML <xref target="XML" format="default"/>, and Concise Binary Object Representation (CBOR) <xref target="RFC8949" format="default"/>. Best practices for their use are out of scope for this document.</t>
        <t>Applications should register distinct media types for each format they define; this makes it possible to identify them unambiguously and negotiate for their use. See <xref target="RFC6838" format="default"/> for more information.</t>
      </section>
      <section anchor="caching" numbered="true" toc="default">
        <name>Leveraging HTTP Caching</name>
        <t>HTTP caching <xref target="HTTP-CACHING" format="default"/> is one of the primary benefits of using HTTP for applications; it provides scalability, reduces latency, and improves reliability. Furthermore, HTTP caches are readily available in browsers and other clients, networks as forward and reverse proxies, content delivery networks, and as part of server software.</t>
        <t>Even when an application using HTTP isn't designed to take advantage of caching, it needs to consider how caches will handle its responses to preserve correct behaviour when one is interposed (whether in the network, server, client, or intervening infrastructure).</t>
        <section anchor="freshness" numbered="true" toc="default">
          <name>Freshness</name>
          <t>Assigning even a short freshness lifetime (<xref section="4.2" sectionFormat="comma" target="HTTP-CACHING" format="default"/>) -- e.g., 5 seconds -- allows a response to be reused to satisfy multiple clients and/or a single client making the same request repeatedly. In general, if it is safe to reuse something, consider assigning a freshness lifetime.</t>
          <t>The most common method for specifying freshness is the max-age response directive (<xref section="5.2.2.1" sectionFormat="comma" target="HTTP-CACHING" format="default"/>). The Expires header field (<xref section="5.3" sectionFormat="comma" target="HTTP-CACHING" format="default"/>) can also be used, but it is not necessary; all modern cache implementations support the Cache-Control header field, and specifying freshness as a delta is usually more convenient and less error-prone.</t>
          <t>It is not necessary to add the public response directive (<xref section="5.2.2.9" sectionFormat="comma" target="HTTP-CACHING" format="default"/>) to cache most responses; it is only necessary when it's desirable to store an authenticated response, or when the status code isn't understood by the cache and there isn't explicit freshness information available.</t>
          <t>In some situations, responses without explicit cache freshness directives will be stored and served using a heuristic freshness lifetime; see <xref section="4.2.2" sectionFormat="comma" target="HTTP-CACHING" format="default"/>. As the heuristic is not under the control of the application, it is generally preferable to set an explicit freshness lifetime or make the response explicitly uncacheable.</t>
          <t>If caching of a response is not desired, the appropriate cache response directive is no-store. Other directives are not necessary, and no-store only needs to be sent in situations where the response might be cached; see <xref section="3" sectionFormat="comma" target="HTTP-CACHING" format="default"/>. Note that the no-cache directive allows a response to be stored, just not reused by a cache without validation; it does not prevent caching (despite its name).</t>
          <t>For example, this response cannot be stored or reused by a cache:</t>
          <sourcecode type="http-message"><![CDATA[
HTTP/1.1 200 OK
Content-Type: application/example+xml
Cache-Control: no-store

[content]
]]></sourcecode>
        </section>
        <section anchor="stale-responses" numbered="true" toc="default">
          <name>Stale Responses</name>
          <t>Authors should understand that stale responses (e.g., with Cache-Control: max-age=0) can be reused by caches when disconnected from the origin server; this can be useful for handling network issues.</t>
          <t>If doing so is not suitable for a given response, the origin should send the must-revalidate cache directive. See <xref section="4.2.4" sectionFormat="of" target="HTTP-CACHING" format="default"/> and also <xref target="RFC5861" format="default"/> for additional controls over stale content.</t>
          <t>Stale responses can be refreshed by assigning a validator, saving both transfer bandwidth and latency for large responses; see <xref section="13" sectionFormat="of" target="HTTP" format="default"/>.</t>
        </section>
        <section anchor="caching-app-semantics" numbered="true" toc="default">
          <name>Caching and Application Semantics</name>
          <t>When an application has a need to express a lifetime that's separate from the freshness lifetime, this should be conveyed separately, either in the response's content or in a separate header field. When this happens, the relationship between HTTP caching and that lifetime needs to be carefully considered since the response will be used as long as it is considered fresh.</t>
          <t>In particular, application authors need to consider how responses that are not freshly obtained from the origin server should be handled; if they have a concept like a validity period, this will need to be calculated considering the age of the response (see <xref section="4.2.3" sectionFormat="comma" target="HTTP-CACHING" format="default"/>).</t>
          <t>One way to address this is to explicitly specify that responses need to be fresh upon use.</t>
        </section>
        <section anchor="varying-content-based-upon-the-request" numbered="true" toc="default">
          <name>Varying Content Based Upon the Request</name>
          <t>If an application uses a request header field to change the response's header fields or content, authors should point out that this has implications for caching; in general, such resources need to either make their responses uncacheable (e.g., with the no-store cache directive defined in <xref section="5.2.2.5" sectionFormat="comma" target="HTTP-CACHING" format="default"/>) or send the Vary response header field (<xref section="12.5.5" sectionFormat="comma" target="HTTP" format="default"/>) on all responses from that resource (including the "default" response).</t>
          <t>For example, this response:</t>
          <sourcecode type="http-message"><![CDATA[
HTTP/1.1 200 OK
Content-Type: application/example+xml
Cache-Control: max-age=60
ETag: "sa0f8wf20fs0f"
Vary: Accept-Encoding

[content]
]]></sourcecode>
          <t>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 request header field.</t>
        </section>
      </section>
      <section anchor="state" numbered="true" toc="default">
        <name>Handling Application State</name>
        <t>Applications can use stateful cookies <xref target="COOKIES" format="default"/> to identify a client and/or store client-specific data to contextualise requests.</t>
        <t>When used, it is important to carefully specify the scoping and use of cookies; if the application exposes sensitive data or capabilities (e.g., by acting as an ambient authority), exploits are possible. Mitigations include using a request-specific token to ensure the intent of the client.</t>
      </section>
      <section anchor="multiplex" numbered="true" toc="default">
        <name>Making Multiple Requests</name>
        <t>Clients often need to send multiple requests to perform a task.</t>
        <t>In HTTP/1 <xref target="HTTP11" format="default"/>, parallel requests are most often supported by opening multiple connections. Application performance can be impacted when too many simultaneous connections are used because connections' congestion control will not be coordinated. Furthermore, it can be difficult for applications to decide when to issue and which connection to use for a given request, further impacting performance.</t>
        <t>HTTP/2 <xref target="HTTP2" format="default"/> and HTTP/3 <xref target="HTTP3" format="default"/> offer multiplexing to applications, removing the need to use multiple connections. However, application performance can still be significantly affected by how the server chooses to prioritize responses. Depending on the application, it might be best for the server to determine the priority of responses or for the client to hint its priorities to the server (see, e.g., <xref target="HTTP-PRIORITY" format="default"/>).</t>
        <t>In all versions of HTTP, requests are made independently -- you can't rely on the relative order of two requests to guarantee their processing order. This is because they might be sent over a multiplexed protocol by an intermediary or sent to different origin servers, or the server might even perform processing in a different order. If two requests need strict ordering, the only reliable way to ensure the outcome is to issue the second request when the final response to the first has begun.</t>
        <t>Applications <bcp14>MUST NOT</bcp14> make assumptions about the relationship between separate requests on a single transport connection; doing so breaks many of the assumptions of HTTP as a stateless protocol and will cause problems in interoperability, security, operability, and evolution.</t>
      </section>
      <section anchor="client-auth" numbered="true" toc="default">
        <name>Client Authentication</name>
        <t>Applications can use HTTP authentication (<xref section="11" sectionFormat="of" target="HTTP" format="default"/>) to identify clients. Per <xref target="RFC7617" format="default"/>, the Basic authentication scheme is not suitable for protecting sensitive or valuable information unless the channel is secure (e.g., using the "https" URI scheme). Likewise, <xref target="RFC7616" format="default"/> requires the Digest authentication scheme to be used over a secure channel.</t>
        <t>With HTTPS, clients might also be authenticated using certificates <xref target="RFC8446" format="default"/>, but note that such authentication is intrinsically scoped to the underlying transport connection. As a result, a client has no way of knowing whether the authenticated status was used in preparing the response (though Vary: * and/or the private cache directive can provide a partial indication), and the only way to obtain a specifically unauthenticated response is to open a new connection.</t>
        <t>When used, it is important to carefully specify the scoping and use of authentication; if the application exposes sensitive data or capabilities (e.g., by acting as an ambient authority; see <xref section="8.3" sectionFormat="of" target="RFC6454" format="default"/>), exploits are possible. Mitigations include using a request-specific token to ensure the intent of the client.</t>
      </section>
      <section anchor="browser" numbered="true" toc="default">
        <name>Coexisting with Web Browsing</name>
        <t>Even if there is not an intent for an application to be used with a Web browser, its resources will remain available to browsers and other HTTP clients. This means that all such applications that use HTTP need to consider how browsers will interact with them, particularly regarding security.</t>
        <t>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 forgery (CSRF) from arbitrary Web sites.</t>
        <t>Or, if an attacker gains control of content returned from the application's resources (for example, part of the request is reflected in the response, or the response contains external information that the attacker can change), they can inject code into the browser and access data and capabilities as if they were the origin -- a technique known as a cross-site scripting (XSS) attack.</t>
        <t>This is only a small sample of the kinds of issues that applications using HTTP must consider. Generally, the best approach is to actually consider the application as a Web application, and to follow best practices for their secure development.</t>
        <t>A complete enumeration of such practices is out of scope for this document, but some considerations include:</t>
        <ul spacing="normal">
          <li>Using an application-specific media type in the Content-Type header field, and requiring clients to fail if it is not used.</li>
          <li>Using X-Content-Type-Options: nosniff <xref target="FETCH" format="default"/> to ensure that content under attacker control can't be coaxed into a form that is interpreted as active content by a Web browser.</li>
          <li>Using Content-Security-Policy <xref target="CSP" format="default"/> to constrain the capabilities of active content (i.e., that which can execute scripts, such as HTML <xref target="HTML" format="default"/> and PDF), thereby mitigating XSS attacks.</li>
          <li>Using Referrer-Policy <xref target="REFERRER-POLICY" format="default"/> to prevent sensitive data in URLs from being leaked in the Referer request header field.</li>
          <li>Using the 'HttpOnly' flag on Cookies to ensure that cookies are not exposed to browser scripting languages <xref target="COOKIES" format="default"/>.</li>
          <li>Avoiding use of compression on any sensitive information (e.g., authentication tokens, passwords), as the scripting environment offered by Web browsers allows an attacker to repeatedly probe the compression space; if the attacker has access to the network path of the communication, they can use this capability to recover that information.</li>
        </ul>
        <t>Depending on how they are intended to be deployed, specifications for applications using HTTP might require the use of these mechanisms in specific ways or might merely point them out in Security Considerations.</t>
        <t>An example of an HTTP response from an application that does not intend for its content to be treated as active by browsers might look like this:</t>
        <sourcecode type="http-message"><![CDATA[
HTTP/1.1 200 OK
Content-Type: application/example+json
X-Content-Type-Options: nosniff
Content-Security-Policy: default-src 'none'
Cache-Control: max-age=3600
Referrer-Policy: no-referrer

[content]
]]></sourcecode>
        <t>If an application has browser compatibility as a goal, client interaction ought to be defined in terms of <xref target="FETCH" format="default"/> since that is the abstraction that browsers use for HTTP; it enforces many of these best practices.</t>
      </section>
      <section anchor="other-apps" numbered="true" toc="default">
        <name>Maintaining Application Boundaries</name>
        <t>Because many HTTP capabilities are scoped to the origin <xref target="RFC6454" format="default"/>, applications also need to consider how deployments might interact with other applications (including Web browsing) that use the same origin server.</t>
        <t>For example, if cookies <xref target="COOKIES" format="default"/> are used to carry application state, they will be sent with all requests to the origin by default (unless scoped by path), and the application might receive cookies from other applications on the origin server. This can lead to security issues as well as collision in cookie names.</t>
        <t>One solution to these issues is to require a dedicated hostname for the application so that it has a unique origin. However, it is often desirable to allow multiple applications to be deployed on a single hostname; doing so provides the most deployment flexibility and enables them to be "mixed" together (see <xref target="BCP190" format="default"/> for details).</t>
        <t>Therefore, applications using HTTP should strive to allow multiple applications on an origin. Specifically, when specifying the use of cookies, HTTP authentication realms <xref target="HTTP" format="default"/>, or other origin-wide HTTP mechanisms, applications using HTTP should not mandate the use of a particular name but instead let deployments configure them. Consideration should be given to scoping them to part of the origin, using their specified mechanisms for doing so.</t>
        <t>Modern Web browsers constrain the ability of content from one origin to access resources from another to avoid leaking private information. As a result, applications that wish to expose cross-origin data to browsers will need to implement the CORS protocol; see <xref target="FETCH" format="default"/>.</t>
      </section>
      <section anchor="server-push" numbered="true" toc="default">
        <name>Using Server Push</name>
        <t>HTTP/2 added the ability for servers to "push" request/response pairs to clients in <xref section="8.4" sectionFormat="comma" target="HTTP2" format="default"/>. While server push seems like a natural fit for many common application semantics (e.g., "fanout" and publish/subscribe), a few caveats should be noted:</t>
        <ul spacing="normal">
          <li>Server push is hop by hop; that is, it is not automatically forwarded by intermediaries. As a result, it might not work easily (or at all) with proxies, reverse proxies, and content delivery networks.</li>
          <li>Server push can have a negative performance impact on HTTP when used incorrectly, particularly if there is contention with resources that have actually been requested by the client.</li>
          <li>Server push is implemented differently in different clients, especially regarding interaction with HTTP caching, and capabilities might vary.</li>
          <li>APIs for server push are currently unavailable in some implementations and vary widely in others. In particular, there is no current browser API for it.</li>
          <li>Server push is not supported in HTTP/1.1 or HTTP/1.0.</li>
          <li>Server push does not form part of the "core" semantics of HTTP and therefore might not be supported by future versions of the protocol.</li>
        </ul>
        <t>Applications wishing to optimise cases where the client can perform work related to requests before the full response is available (e.g., fetching links for things likely to be contained within) might benefit from using the 103 (Early Hints) status code; see <xref target="RFC8297" format="default"/>.</t>
        <t>Applications using server push directly need to enforce the requirements regarding authority in <xref section="8.4" sectionFormat="comma" target="HTTP2" format="default"/> to avoid cross-origin push attacks.</t>
      </section>
      <section anchor="versioning" numbered="true" toc="default">
        <name>Allowing Versioning and Evolution</name>
        <t>It's often necessary to introduce new features into application protocols and change existing ones.</t>
        <t>In HTTP, backwards-incompatible changes can be made using mechanisms such as:</t>
        <ul spacing="normal">
          <li>Using a distinct link relation type <xref target="WEB-LINKING" format="default"/> to identify a URL for a resource that implements the new functionality.</li>
          <li>Using a distinct media type <xref target="RFC6838" format="default"/> to identify formats that enable the new functionality.</li>
          <li>Using a distinct HTTP header field to implement new functionality outside the message content.</li>
        </ul>
      </section>
    </section>
    <section anchor="iana-considerations" numbered="true" toc="default">
      <name>IANA Considerations</name>
      <t>This document has no IANA actions.</t>
    </section>
    <section anchor="security-considerations" numbered="true" toc="default">
      <name>Security Considerations</name>
      <t>Applications using HTTP are subject to the security considerations of HTTP itself and any extensions used; <xref target="HTTP" format="default"/>, <xref target="HTTP-CACHING" format="default"/>, and <xref target="WEB-LINKING" format="default"/> are often relevant, amongst others.</t>
      <t><xref target="scheme" format="default"/> recommends support for "https" URLs and discourages the use of "http" URLs to provide authentication, integrity, and confidentiality, as well as to mitigate pervasive monitoring attacks. Many applications using HTTP perform authentication and authorization with bearer tokens (e.g., in session cookies). If the transport is unencrypted, an attacker that can eavesdrop upon or modify HTTP communications can often escalate their privilege to perform operations on resources.</t>
      <t><xref target="caching-app-semantics" format="default"/> highlights the potential for mismatch between HTTP caching and application-specific storage of responses or information therein.</t>
      <t><xref target="state" format="default"/> discusses the impact of using stateful mechanisms in the protocol as ambient authority and suggests a mitigation.</t>
      <t><xref target="browser" format="default"/> highlights the implications of Web browsers' capabilities on applications that use HTTP.</t>
      <t><xref target="other-apps" format="default"/> discusses the issues that arise when applications are deployed on the same origin as websites (and other applications).</t>
      <t><xref target="server-push" format="default"/> highlights risks of using HTTP/2 server push in a manner other than that specified.</t>
      <t>Applications that use HTTP in a manner that involves modification of implementations -- for example, requiring support for a new URI scheme or a non-standard method -- risk having those implementations "fork" from their parent HTTP implementations, with the possible result that they do not benefit from patches and other security improvements incorporated upstream.</t>
      <section anchor="privacy-considerations" numbered="true" toc="default">
        <name>Privacy Considerations</name>
        <t>HTTP clients can expose a variety of information to servers. Besides information that's explicitly sent as part of an application's operation (for example, names and other user-entered data) and "on the wire" (which is one of the reasons "https" is recommended in <xref target="scheme" format="default"/>), other information can be gathered through less obvious means -- often by connecting activities of a user over time.</t>
        <t>This includes session information, tracking the client through fingerprinting, and code execution.</t>
        <t>Session information includes things like the IP address of the client, TLS session tickets, Cookies, ETags stored in the client's cache, and other stateful mechanisms. Applications are advised to avoid using session mechanisms unless they are unavoidable or necessary for operation, in which case these risks need to be documented. When they are used, implementations should be encouraged to allow clearing such state.</t>
        <t>Fingerprinting uses unique aspects of a client's messages and behaviours to connect disparate requests and connections. For example, the User-Agent request header field conveys specific information about the implementation; the Accept-Language request header field conveys the users' preferred language. In combination, a number of these markers can be used to uniquely identify a client, impacting its control over its data. As a result, applications are advised to specify that clients should only emit the information they need to function in requests.</t>
        <t>Finally, if an application exposes the ability to execute code, great care needs to be taken since any ability to observe its environment can be used as an opportunity to both fingerprint the client and to obtain and manipulate private data (including session information). For example, access to high-resolution timers (even indirectly) can be used to profile the underlying hardware, creating a unique identifier for the system. Applications are advised to avoid allowing the use of mobile code where possible; when it cannot be avoided, the resulting system's security properties need be carefully scrutinised.</t>
      </section>
    </section>
  </middle>
  <back>
    <displayreference target="HTTP11" to="HTTP/1.1"/>
    <displayreference target="HTTP2" to="HTTP/2"/>
    <displayreference target="HTTP3" to="HTTP/3"/>
    <references>
      <name>References</name>
      <references>
        <name>Normative References</name>
        <reference anchor="HTTP" target="https://www.rfc-editor.org/info/rfc9110">
          <front>
            <title>HTTP Semantics</title>
            <author initials="R" surname="Fielding" fullname="Roy Fielding" role="editor">
              <organization />
            </author>
            <author initials="M" surname="Nottingham" fullname="Mark Nottingham" role="editor">
             <organization />
           </author>
           <author initials="J" surname="Reschke" fullname="Julian Reschke" role="editor">
             <organization />
           </author>
           <date year="2022" month="June" />
          </front>
          <seriesInfo name="STD" value="97"/>
          <seriesInfo name="RFC" value="9110"/>
          <seriesInfo name="DOI" value="10.17487/RFC9110"/>
        </reference>
        <reference anchor="HTTP-CACHING" target="https://www.rfc-editor.org/info/rfc9111">
          <front>
            <title>HTTP Caching</title>
            <author initials="R" surname="Fielding" fullname="Roy Fielding" role="editor">
              <organization />
            </author>
            <author initials="M" surname="Nottingham" fullname="Mark Nottingham" role="editor">
             <organization />
           </author>
           <author initials="J" surname="Reschke" fullname="Julian Reschke" role="editor">
             <organization />
           </author>
           <date year="2022" month="June"/>
          </front>
          <seriesInfo name="STD" value="98"/>
          <seriesInfo name="RFC" value="9111"/>
          <seriesInfo name="DOI" value="10.17487/RFC9111"/>
        </reference>
        <reference anchor="WEB-LINKING" target="https://www.rfc-editor.org/info/rfc8288">
          <front>
            <title>Web Linking</title>
            <author fullname="M. Nottingham" initials="M." surname="Nottingham">
              <organization/>
            </author>
            <date month="October" year="2017"/>
          </front>
          <seriesInfo name="RFC" value="8288"/>
          <seriesInfo name="DOI" value="10.17487/RFC8288"/>
        </reference>
        <reference anchor="URL" target="https://www.rfc-editor.org/info/rfc3986">
          <front>
            <title>Uniform Resource Identifier (URI): Generic Syntax</title>
            <author fullname="T. Berners-Lee" initials="T." surname="Berners-Lee">
              <organization/>
            </author>
            <author fullname="R. Fielding" initials="R." surname="Fielding">
              <organization/>
            </author>
            <author fullname="L. Masinter" initials="L." surname="Masinter">
              <organization/>
            </author>
            <date month="January" year="2005"/>
          </front>
          <seriesInfo name="STD" value="66"/>
          <seriesInfo name="RFC" value="3986"/>
          <seriesInfo name="DOI" value="10.17487/RFC3986"/>
        </reference>
        <reference anchor="WELL-KNOWN-URI" target="https://www.rfc-editor.org/info/rfc8615">
          <front>
            <title>Well-Known Uniform Resource Identifiers (URIs)</title>
            <author fullname="M. Nottingham" initials="M." surname="Nottingham">
              <organization/>
            </author>
            <date month="May" year="2019"/>
          </front>
          <seriesInfo name="RFC" value="8615"/>
          <seriesInfo name="DOI" value="10.17487/RFC8615"/>
        </reference>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8174.xml"/>
        <reference anchor="BCP190">
          <front>
            <title>URI Design and Ownership</title>
            <author fullname="M. Nottingham" initials="M." surname="Nottingham">
              <organization/>
            </author>
            <date month="June" year="2020"/>
          </front>
          <seriesInfo name="BCP" value="190"/>
          <seriesInfo name="RFC" value="8820"/>
          <seriesInfo name="DOI" value="10.17487/RFC8820"/>
        </reference>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.6838.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.6454.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.6648.xml"/>
        <reference anchor="STRUCTURED-FIELDS" target="https://www.rfc-editor.org/info/rfc8941">
          <front>
            <title>Structured Field Values for HTTP</title>
            <author fullname="M. Nottingham" initials="M." surname="Nottingham">
              <organization/>
            </author>
            <author fullname="P-H. Kamp" initials="P-H." surname="Kamp">
              <organization/>
            </author>
            <date month="February" year="2021"/>
          </front>
          <seriesInfo name="RFC" value="8941"/>
          <seriesInfo name="DOI" value="10.17487/RFC8941"/>
        </reference>
    </references>
    <references>
        <name>Informative References</name>
        <reference anchor="HTTP11" target="https://www.rfc-editor.org/info/rfc9112">
          <front>
            <title>HTTP/1.1</title>
            <author initials="R" surname="Fielding" fullname="Roy Fielding" role="editor">
              <organization />
            </author>
            <author initials="M" surname="Nottingham" fullname="Mark Nottingham" role="editor">
             <organization />
           </author>
           <author initials="J" surname="Reschke" fullname="Julian Reschke" role="editor">
             <organization />
           </author>
           <date year="2022" month="June" />
          </front>
          <seriesInfo name="STD" value="99"/>
          <seriesInfo name="RFC" value="9112"/>
          <seriesInfo name="DOI" value="10.17487/RFC9112"/>
        </reference>
        <reference anchor="HTTP2" target="https://www.rfc-editor.org/info/rfc9113">
          <front>
            <title>HTTP/2</title>
            <author initials="M" surname="Thomson" fullname="Martin Thomson" role="editor">
              <organization/>
            </author>
            <author initials="C" surname="Benfield" fullname="Cory Benfield" role="editor">
              <organization/>
            </author>
            <date  month="June" year="2022"/>
          </front>
          <seriesInfo name="RFC" value="9113"/>
          <seriesInfo name="DOI" value="10.17487/RFC9113"/>
        </reference>
        <reference anchor="HTTP3" target="https://www.rfc-editor.org/info/rfc9114">
          <front>
            <title>HTTP/3</title>
            <author initials="M" surname="Bishop" fullname="Mike Bishop" role="editor">
              <organization />
            </author>
            <date year="2022" month="June" />
          </front>
          <seriesInfo name="RFC" value="9114"/>
          <seriesInfo name="DOI" value="10.17487/RFC9114"/>
        </reference>
        <reference anchor="JSON" target="https://www.rfc-editor.org/info/rfc8259">
          <front>
            <title>The JavaScript Object Notation (JSON) Data Interchange Format</title>
            <author fullname="T. Bray" initials="T." role="editor" surname="Bray">
              <organization/>
            </author>
            <date month="December" year="2017"/>
          </front>
          <seriesInfo name="STD" value="90"/>
          <seriesInfo name="RFC" value="8259"/>
          <seriesInfo name="DOI" value="10.17487/RFC8259"/>
        </reference>
        <reference anchor="URI-TEMPLATE" target="https://www.rfc-editor.org/info/rfc6570">
          <front>
            <title>URI Template</title>
            <author fullname="J. Gregorio" initials="J." surname="Gregorio">
              <organization/>
            </author>
            <author fullname="R. Fielding" initials="R." surname="Fielding">
              <organization/>
            </author>
            <author fullname="M. Hadley" initials="M." surname="Hadley">
              <organization/>
            </author>
            <author fullname="M. Nottingham" initials="M." surname="Nottingham">
              <organization/>
            </author>
            <author fullname="D. Orchard" initials="D." surname="Orchard">
              <organization/>
            </author>
            <date month="March" year="2012"/>
          </front>
          <seriesInfo name="RFC" value="6570"/>
          <seriesInfo name="DOI" value="10.17487/RFC6570"/>
        </reference>
        <reference anchor="COOKIES" target="https://www.rfc-editor.org/info/rfc6265">
          <front>
            <title>HTTP State Management Mechanism</title>
            <author fullname="A. Barth" initials="A." surname="Barth">
              <organization/>
            </author>
            <date month="April" year="2011"/>
          </front>
          <seriesInfo name="RFC" value="6265"/>
          <seriesInfo name="DOI" value="10.17487/RFC6265"/>
        </reference>
        <reference anchor="PROBLEM-DETAILS" target="https://www.rfc-editor.org/info/rfc7807">
          <front>
            <title>Problem Details for HTTP APIs</title>
            <author fullname="M. Nottingham" initials="M." surname="Nottingham">
              <organization/>
            </author>
            <author fullname="E. Wilde" initials="E." surname="Wilde">
              <organization/>
            </author>
            <date month="March" year="2016"/>
          </front>
          <seriesInfo name="RFC" value="7807"/>
          <seriesInfo name="DOI" value="10.17487/RFC7807"/>
        </reference>
        <reference anchor="HTTP-PRIORITY" target="https://www.rfc-editor.org/info/rfc9218">
          <front>
            <title>Extensible Prioritization Scheme for HTTP</title>
            <author asciiFullname="Kazuho Oku" fullname="奥 一穂">
              <organization/>
            </author>
            <author initials="L" surname="Pardue" fullname="Lucas Pardue">
              <organization/>
            </author>
            <date month="June" year="2022"/>
          </front>
          <seriesInfo name="RFC" value="9218"/>
          <seriesInfo name="DOI" value="10.17487/RFC9218"/>
        </reference>
        <reference anchor="HTML" target="https://html.spec.whatwg.org">
          <front>
            <title>HTML - Living Standard</title>
            <author>
              <organization>WHATWG</organization>
            </author>
            <date/>
          </front>
        </reference>
        <reference anchor="FETCH" target="https://fetch.spec.whatwg.org">
          <front>
            <title>Fetch - Living Standard</title>
            <author>
              <organization>WHATWG</organization>
            </author>
            <date/>
          </front>
        </reference>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.3205.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.7301.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.7258.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.6797.xml"/>
        <reference anchor="SECCTXT" target="https://www.w3.org/TR/2021/CRD-secure-contexts-20210918">
          <front>
            <title>Secure Contexts</title>
            <author fullname="Mike West" initials="M." surname="West">
              <organization/>
            </author>
            <date  month="September" year="2021"/>
          </front>
          <refcontent>W3C Candidate Recommendation</refcontent>
        </reference>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.7595.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.7605.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.4791.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8470.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.4918.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.6415.xml"/>
        <reference anchor="XML" target="https://www.w3.org/TR/2008/REC-xml-20081126">
          <front>
            <title>Extensible Markup Language (XML) 1.0 (Fifth Edition)</title>
            <author fullname="Tim Bray" initials="T." surname="Bray">
              <organization/>
            </author>
            <author fullname="Jean Paoli" initials="J." surname="Paoli">
              <organization/>
            </author>
            <author fullname="Michael Sperberg-McQueen" initials="M." surname="Sperberg-McQueen">
              <organization/>
            </author>
            <author fullname="Eve Maler" initials="E." surname="Maler">
              <organization/>
            </author>
            <author fullname="François Yergeau" initials="F." surname="Yergeau">
              <organization/>
            </author>
            <date month="November" year="2008"/>
          </front>
          <seriesInfo name="W3C Recommendation" value="REC-xml-20081126"/>
        </reference>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8949.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.5861.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.7617.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.7616.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8446.xml"/>
        <reference anchor="CSP" target="https://www.w3.org/TR/2021/WD-CSP3-20210629">
          <front>
            <title>Content Security Policy Level 3</title>
            <author fullname="Mike West" initials="M." surname="West">
              <organization/>
            </author>
            <date month="June" year="2021"/>
          </front>
          <refcontent>W3C Working Draft</refcontent>
        </reference>
        <reference anchor="REFERRER-POLICY" target="https://www.w3.org/TR/2017/CR-referrer-policy-20170126">
          <front>
            <title>Referrer Policy</title>
            <author fullname="Jochen Eisinger" initials="J." surname="Eisinger">
              <organization/>
            </author>
            <author fullname="Emily Stark" initials="E." surname="Stark">
              <organization/>
            </author>
            <date month="January" year="2017"/>
          </front>
          <refcontent>W3C Candidate Recommendation CR-referrer-policy-20170126</refcontent>
        </reference>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8297.xml"/>
      </references>
    </references>
    <section anchor="changes-from-rfc-3205" numbered="true" toc="default">
      <name>Changes from RFC 3205</name>
      <t><xref target="RFC3205" format="default"/> captured the Best Current Practice in the early 2000s based on the concerns facing protocol designers at the time. Use of HTTP has changed considerably since then; as a result, this document is substantially different. Consequently, the changes are too numerous to list individually.</t>
    </section>
  </back>
</rfc>
