idnits 2.17.00 (12 Aug 2021) /tmp/idnits42920/draft-ietf-httpbis-bcp56bis-15.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- ** The abstract seems to contain references ([RFC3205]), which it shouldn't. Please replace those with straight textual mentions of the documents in question. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (27 August 2021) is 260 days in the past. Is this intentional? Checking references for intended status: Best Current Practice ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) == Missing Reference: 'RFC8259' is mentioned on line 432, but not defined == Outdated reference: A later version (-19) exists of draft-ietf-httpbis-semantics-18 -- Possible downref: Normative reference to a draft: ref. 'HTTP' == Outdated reference: A later version (-19) exists of draft-ietf-httpbis-cache-18 -- Possible downref: Normative reference to a draft: ref. 'HTTP-CACHING' == Outdated reference: A later version (-12) exists of draft-ietf-httpbis-priority-04 == Outdated reference: A later version (-19) exists of draft-ietf-httpbis-messaging-18 == Outdated reference: A later version (-07) exists of draft-ietf-httpbis-http2bis-03 Summary: 1 error (**), 0 flaws (~~), 7 warnings (==), 3 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 HTTP M. Nottingham 3 Internet-Draft 27 August 2021 4 Obsoletes: 3205 (if approved) 5 Intended status: Best Current Practice 6 Expires: 28 February 2022 8 Building Protocols with HTTP 9 draft-ietf-httpbis-bcp56bis-15 11 Abstract 13 Applications often use HTTP as a substrate to create HTTP-based APIs. 14 This document specifies best practices for writing specifications 15 that use HTTP to define new application protocols. It is written 16 primarily to guide IETF efforts to define application protocols using 17 HTTP for deployment on the Internet, but might be applicable in other 18 situations. 20 This document obsoletes [RFC3205]. 22 Note to Readers 24 _RFC EDITOR: please remove this section before publication_ 26 Discussion of this draft takes place on the HTTP working group 27 mailing list (ietf-http-wg@w3.org), which is archived at 28 https://lists.w3.org/Archives/Public/ietf-http-wg/ 29 (https://lists.w3.org/Archives/Public/ietf-http-wg/). 31 Working Group information can be found at http://httpwg.github.io/ 32 (http://httpwg.github.io/); source code and issues list for this 33 draft can be found at https://github.com/httpwg/http- 34 extensions/labels/bcp56bis (https://github.com/httpwg/http- 35 extensions/labels/bcp56bis). 37 Status of This Memo 39 This Internet-Draft is submitted in full conformance with the 40 provisions of BCP 78 and BCP 79. 42 Internet-Drafts are working documents of the Internet Engineering 43 Task Force (IETF). Note that other groups may also distribute 44 working documents as Internet-Drafts. The list of current Internet- 45 Drafts is at https://datatracker.ietf.org/drafts/current/. 47 Internet-Drafts are draft documents valid for a maximum of six months 48 and may be updated, replaced, or obsoleted by other documents at any 49 time. It is inappropriate to use Internet-Drafts as reference 50 material or to cite them other than as "work in progress." 52 This Internet-Draft will expire on 28 February 2022. 54 Copyright Notice 56 Copyright (c) 2021 IETF Trust and the persons identified as the 57 document authors. All rights reserved. 59 This document is subject to BCP 78 and the IETF Trust's Legal 60 Provisions Relating to IETF Documents (https://trustee.ietf.org/ 61 license-info) in effect on the date of publication of this document. 62 Please review these documents carefully, as they describe your rights 63 and restrictions with respect to this document. Code Components 64 extracted from this document must include Simplified BSD License text 65 as described in Section 4.e of the Trust Legal Provisions and are 66 provided without warranty as described in the Simplified BSD License. 68 Table of Contents 70 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3 71 1.1. Notational Conventions . . . . . . . . . . . . . . . . . 5 72 2. Is HTTP Being Used? . . . . . . . . . . . . . . . . . . . . . 5 73 2.1. Non-HTTP Protocols . . . . . . . . . . . . . . . . . . . 5 74 3. What's Important About HTTP . . . . . . . . . . . . . . . . . 6 75 3.1. Generic Semantics . . . . . . . . . . . . . . . . . . . . 6 76 3.2. Links . . . . . . . . . . . . . . . . . . . . . . . . . . 7 77 3.3. Rich Functionality . . . . . . . . . . . . . . . . . . . 7 78 4. Best Practices for Specifying the Use of HTTP . . . . . . . . 8 79 4.1. Specifying the Use of HTTP . . . . . . . . . . . . . . . 8 80 4.2. Specifying Server Behaviour . . . . . . . . . . . . . . . 9 81 4.3. Specifying Client Behaviour . . . . . . . . . . . . . . . 10 82 4.4. Specifying URLs . . . . . . . . . . . . . . . . . . . . . 11 83 4.4.1. Discovering an Application's URLs . . . . . . . . . . 11 84 4.4.2. Considering URI Schemes . . . . . . . . . . . . . . . 12 85 4.4.3. Transport Ports . . . . . . . . . . . . . . . . . . . 13 86 4.5. Using HTTP Methods . . . . . . . . . . . . . . . . . . . 14 87 4.5.1. GET . . . . . . . . . . . . . . . . . . . . . . . . . 14 88 4.5.2. OPTIONS . . . . . . . . . . . . . . . . . . . . . . . 15 89 4.6. Using HTTP Status Codes . . . . . . . . . . . . . . . . . 16 90 4.6.1. Redirection . . . . . . . . . . . . . . . . . . . . . 17 91 4.7. Specifying HTTP Header Fields . . . . . . . . . . . . . . 18 92 4.8. Defining Message Content . . . . . . . . . . . . . . . . 20 93 4.9. Leveraging HTTP Caching . . . . . . . . . . . . . . . . . 20 94 4.9.1. Freshness . . . . . . . . . . . . . . . . . . . . . . 20 95 4.9.2. Stale Responses . . . . . . . . . . . . . . . . . . . 21 96 4.9.3. Caching and Application Semantics . . . . . . . . . . 21 97 4.9.4. Varying Content Based Upon the Request . . . . . . . 22 98 4.10. Handling Application State . . . . . . . . . . . . . . . 22 99 4.11. Making Multiple Requests . . . . . . . . . . . . . . . . 22 100 4.12. Client Authentication . . . . . . . . . . . . . . . . . . 23 101 4.13. Co-Existing with Web Browsing . . . . . . . . . . . . . . 24 102 4.14. Maintaining Application Boundaries . . . . . . . . . . . 25 103 4.15. Using Server Push . . . . . . . . . . . . . . . . . . . . 26 104 4.16. Allowing Versioning and Evolution . . . . . . . . . . . . 27 105 5. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 27 106 6. Security Considerations . . . . . . . . . . . . . . . . . . . 27 107 6.1. Privacy Considerations . . . . . . . . . . . . . . . . . 28 108 7. References . . . . . . . . . . . . . . . . . . . . . . . . . 29 109 7.1. Normative References . . . . . . . . . . . . . . . . . . 29 110 7.2. Informative References . . . . . . . . . . . . . . . . . 30 111 Appendix A. Changes from RFC 3205 . . . . . . . . . . . . . . . 33 112 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 33 114 1. Introduction 116 Applications other than Web browsing often use HTTP [HTTP] as a 117 substrate, a practice sometimes referred to as creating "HTTP-based 118 APIs", "REST APIs" or just "HTTP APIs". This is done for a variety 119 of reasons, including: 121 * familiarity by implementers, specifiers, administrators, 122 developers and users, 124 * availability of a variety of client, server and proxy 125 implementations, 127 * ease of use, 129 * availability of Web browsers, 131 * reuse of existing mechanisms like authentication and encryption, 133 * presence of HTTP servers and clients in target deployments, and 135 * its ability to traverse firewalls. 137 These protocols are often ad hoc, intended for only deployment by one 138 or a few servers and consumption by a limited set of clients. As a 139 result, a body of practices and tools has arisen around defining 140 HTTP-based APIs that favours these conditions. 142 However, when such an application has multiple, separate 143 implementations, is deployed on multiple uncoordinated servers, and 144 is consumed by diverse clients -- as is often the case for HTTP APIs 145 defined by standards efforts -- tools and practices intended for 146 limited deployment can become unsuitable. 148 This mismatch is largely because the API's clients and servers will 149 implement and evolve at different paces, leading to a need for 150 deployments with different features and versions to co-exist. As a 151 result, the designers of HTTP-based APIs intended for such 152 deployments need to more carefully consider how extensibility of the 153 service will be handled and how different deployment requirements 154 will be accommodated. 156 More generally, an application protocol using HTTP faces a number of 157 design decisions, including: 159 * Should it define a new URI scheme? Use new ports? 161 * Should it use standard HTTP methods and status codes, or define 162 new ones? 164 * How can the maximum value be extracted from the use of HTTP? 166 * How does it coexist with other uses of HTTP -- especially Web 167 browsing? 169 * How can interoperability problems and "protocol dead ends" be 170 avoided? 172 This document contains best current practices for the specification 173 of such applications. Section 2 defines when it applies; Section 3 174 surveys the properties of HTTP that are important to preserve, and 175 Section 4 conveys best practices for specifying them. 177 It is written primarily to guide IETF efforts to define application 178 protocols using HTTP for deployment on the Internet, but might be 179 applicable in other situations. Note that the requirements herein do 180 not necessarily apply to the development of generic HTTP extensions. 182 This document obsoletes [RFC3205], to reflect experience and 183 developments regarding HTTP in the intervening time. 185 1.1. Notational Conventions 187 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 188 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 189 "OPTIONAL" in this document are to be interpreted as described in BCP 190 14 [RFC2119] [RFC8174] when, and only when, they appear in all 191 capitals, as shown here. 193 2. Is HTTP Being Used? 195 Different applications have different goals when using HTTP. The 196 recommendations in this document apply when a specification defines 197 an application that: 199 * uses the transport port 80 or 443, or 201 * uses the URI scheme "http" or "https", or 203 * uses an ALPN protocol ID [RFC7301] that generically identifies 204 HTTP (e.g., "http/1.1", "h2", "h3"), or 206 * makes registrations in or overall modifications to the IANA 207 registries defined for HTTP. 209 Additionally, when a specification is using HTTP, all of the 210 requirements of the HTTP protocol suite are in force (in particular, 211 [HTTP], but also other specifications such as the specific version of 212 HTTP in use, and any extensions in use). 214 Note that this document is intended to apply to applications, not 215 generic extensions to HTTP. Furthermore, while it is intended for 216 IETF-specified applications, other standards organisations are 217 encouraged to adhere to its requirements. 219 2.1. Non-HTTP Protocols 221 An application can rely upon HTTP without meeting the criteria for 222 using it defined above. For example, an application might wish to 223 avoid re-specifying parts of the message format, but change other 224 aspects of the protocol's operation; or, it might want to use 225 application-specific methods. 227 Doing so brings more freedom to modify protocol operations, but loses 228 at least a portion of the benefits outlined in Section 3, as most 229 HTTP implementations won't be easily adaptable to these changes, and 230 the benefit of mindshare will be lost. 232 Such specifications MUST NOT use HTTP's URI schemes, transport ports, 233 ALPN protocol IDs or IANA registries; rather, they are encouraged to 234 establish their own. 236 3. What's Important About HTTP 238 This section examines the characteristics of HTTP that are important 239 to consider when using HTTP to define an application protocol. 241 3.1. Generic Semantics 243 Much of the value of HTTP is in its generic semantics -- that is, the 244 protocol elements defined by HTTP are potentially applicable to every 245 resource, not specific to a particular context. Application-specific 246 semantics are best expressed in message content and in header fields, 247 not status codes or methods (although the latter do have generic 248 semantics that relate to application state). 250 This generic/application-specific split allows a HTTP message to be 251 handled by common software (e.g., HTTP servers, intermediaries, 252 client implementations, and caches) without understanding the 253 specific application. It also allows people to leverage their 254 knowledge of HTTP semantics without specialising them for a 255 particular application. 257 Therefore, applications that use HTTP MUST NOT re-define, refine or 258 overlay the semantics of generic protocol elements such as methods, 259 status codes or existing header fields. Instead, they should focus 260 their specifications on protocol elements that are specific to that 261 application; namely their HTTP resources. 263 When writing a specification, it's often tempting to specify exactly 264 how HTTP is to be implemented, supported and used. However, this can 265 easily lead to an unintended profile of HTTP's behaviour. For 266 example, it's common to see specifications with language like this: 268 A `POST` request MUST result in a `201 Created` response. 270 This forms an expectation in the client that the response will always 271 be "201 Created", when in fact there are a number of reasons why the 272 status code might differ in a real deployment; for example, there 273 might be a proxy that requires authentication, or a server-side 274 error, or a redirection. If the client does not anticipate this, the 275 application's deployment is brittle. 277 See Section 4.2 for more details. 279 3.2. Links 281 Another common practice is assuming that the HTTP server's name space 282 (or a portion thereof) is exclusively for the use of a single 283 application. This effectively overlays special, application-specific 284 semantics onto that space, precludes other applications from using 285 it. 287 As explained in [RFC8820], such "squatting" on a part of the URL 288 space by a standard usurps the server's authority over its own 289 resources, can cause deployment issues, and is therefore bad practice 290 in standards. 292 Instead of statically defining URI components like paths, it is 293 RECOMMENDED that applications using HTTP define and use links 294 [WEB-LINKING] to allow flexibility in deployment. 296 Using runtime links in this fashion has a number of other benefits -- 297 especially when an application is to have multiple implementations 298 and/or deployments (as is often the case for those that are 299 standardised). 301 For example, navigating with a link allows a request to be routed to 302 a different server without the overhead of a redirection, thereby 303 supporting deployment across machines well. 305 It also becomes possible to "mix and match" different applications on 306 the same server, and offers a natural mechanism for extensibility, 307 versioning and capability management, since the document containing 308 the links can also contain information about their targets. 310 Using links also offers a form of cache invalidation that's seen on 311 the Web; when a resource's state changes, the application can change 312 its link to it so that a fresh copy is always fetched. 314 3.3. Rich Functionality 316 HTTP offers a number of features to applications, such as: 318 * Message framing 320 * Multiplexing (in HTTP/2 [HTTP2] and HTTP/3 [HTTP3]) 322 * Integration with TLS 324 * Support for intermediaries (proxies, gateways, Content Delivery 325 Networks) 327 * Client authentication 329 * Content negotiation for format, language, and other features 331 * Caching for server scalability, latency and bandwidth reduction, 332 and reliability 334 * Granularity of access control (through use of a rich space of 335 URLs) 337 * Partial content to selectively request part of a response 339 * The ability to interact with the application easily using a Web 340 browser 342 Applications that use HTTP are encouraged to utilise the various 343 features that the protocol offers, so that their users receive the 344 maximum benefit from it, and to allow it to be deployed in a variety 345 of situations. This document does not require specific features to 346 be used, since the appropriate design tradeoffs are highly specific 347 to a given situation. However, following the practices in Section 4 348 is a good starting point. 350 4. Best Practices for Specifying the Use of HTTP 352 This section contains best practices for specifying the use of HTTP 353 by applications, including practices for specific HTTP protocol 354 elements. 356 4.1. Specifying the Use of HTTP 358 Specifications should use [HTTP] as the primary reference for HTTP; 359 it is not necessary to reference all of the specifications in the 360 HTTP suite unless there are specific reasons to do so (e.g., a 361 particular feature is called out). 363 Because HTTP is a hop-by-hop protocol, a connection can be handled by 364 implementations that are not controlled by the application; for 365 example, proxies, CDNs, firewalls and so on. Requiring a particular 366 version of HTTP makes it difficult to use in these situations, and 367 harms interoperability. Therefore, it is NOT RECOMMENDED that 368 applications using HTTP specify a minimum version of HTTP to be used. 370 However, if an application's deployment would benefit from the use of 371 a particular version of HTTP (for example, HTTP/2's multiplexing), 372 this ought be noted. 374 Applications using HTTP MUST NOT specify a maximum version, to 375 preserve the protocol's ability to evolve. 377 When specifying examples of protocol interactions, applications 378 should document both the request and response messages, with complete 379 header sections, preferably in HTTP/1.1 format [HTTP11]. For 380 example: 382 GET /thing HTTP/1.1 383 Host: example.com 384 Accept: application/things+json 385 User-Agent: Foo/1.0 387 HTTP/1.1 200 OK 388 Content-Type: application/things+json 389 Content-Length: 500 390 Server: Bar/2.2 392 [content here] 394 4.2. Specifying Server Behaviour 396 The server-side behaviours of an application are most effectively 397 specified by defining the following protocol elements: 399 * Media types [RFC6838], often based upon a format convention such 400 as JSON [JSON], 402 * HTTP header fields, as per Section 4.7, and 404 * The behaviour of resources, as identified by link relations 405 [WEB-LINKING]. 407 An application can define its operation by composing these protocol 408 elements to define a set of resources that are identified by link 409 relations and that implement specified behaviours, including: 411 * retrieval of their state using GET, in one or more formats 412 identified by media type; 414 * resource creation or update using POST or PUT, with an 415 appropriately identified request content format; 417 * data processing using POST and identified request and response 418 content format(s); and 420 * Resource deletion using DELETE. 422 For example, an application might specify: 424 Resources linked to with the "example-widget" link relation type are 425 Widgets. The state of a Widget can be fetched in the 426 "application/example-widget+json" format, and can be updated by PUT 427 to the same link. Widget resources can be deleted. 429 The "Example-Count" response header field on Widget representations 430 indicates how many Widgets are held by the sender. 432 The "application/example-widget+json" format is a JSON [RFC8259] 433 format representing the state of a Widget. It contains links to 434 related information in the link indicated by the Link header field 435 value with the "example-other-info" link relation type. 437 Applications can also specify the use of URI Templates [URI-TEMPLATE] 438 to allow clients to generate URLs based upon runtime data. 440 4.3. Specifying Client Behaviour 442 An application's expectations for client behaviour ought to be 443 closely aligned with those of Web browsers, to avoid interoperability 444 issues when they are used. 446 One way to do this is to define it in terms of [FETCH], since that is 447 the abstraction that browsers use for HTTP. 449 Some client behaviours (e.g., automatic redirect handling) and 450 extensions (e.g., Cookies) are not required by HTTP, but nevertheless 451 have become very common. If their use is not explicitly specified by 452 applications using HTTP, there may be confusion and interoperability 453 problems. In particular: 455 * Redirect handling - Applications need to specify how redirects are 456 expected to be handled; see Section 4.6.1. 458 * Cookies - Applications using HTTP should explicitly reference the 459 Cookie specification [COOKIES] if they are required. 461 * Certificates - Applications using HTTP should specify that TLS 462 certificates are to be checked according to Section 4.3.4 of 463 [HTTP] when HTTPS is used. 465 Applications using HTTP should not statically require HTTP features 466 that are usually negotiated to be supported by clients. For example, 467 requiring that clients support responses with a certain content- 468 coding ([HTTP], Section 8.4.1) instead of negotiating for it ([HTTP], 469 Section 12.5.3) means that otherwise conformant clients cannot 470 interoperate with the application. Applications can encourage the 471 implementation of such features, though. 473 4.4. Specifying URLs 475 In HTTP, the resources that clients interact with are identified with 476 URLs [URL]. As [RFC8820] explains, parts of the URL are designed to 477 be under the control of the owner (also known as the "authority") of 478 that server, to give them the flexibility in deployment. 480 This means that in most cases, specifications for applications that 481 use HTTP won't contain fixed application URLs or paths; while it is 482 common practice for a specification of a single-deployment API to 483 specify the path prefix "/app/v1" (for example), doing so in an IETF 484 specification is inappropriate. 486 Therefore, the specification writer needs some mechanism to allow 487 clients to discovery an application's URLs. Additionally, they need 488 to specify what URL scheme(s) the application should be used with, 489 and whether to use a dedicated port, or reuse HTTP's port(s). 491 4.4.1. Discovering an Application's URLs 493 Generally, a client will begin interacting with a given application 494 server by requesting an initial document that contains information 495 about that particular deployment, potentially including links to 496 other relevant resources. Doing so assures that the deployment is as 497 flexible as possible (potentially spanning multiple servers), allows 498 evolution, and also gives the application the opportunity to tailor 499 the 'discovery document' to the client. 501 There are a few common patterns for discovering that initial URL. 503 The most straightforward mechanism for URL discovery is to configure 504 the client with (or otherwise convey to it) a full URL. This might 505 be done in a configuration document, or through another discovery 506 mechanism. 508 However, if the client only knows the server's hostname and the 509 identity of the application, there needs to be some way to derive the 510 initial URL from that information. 512 An application cannot define a fixed prefix for its URL paths; see 513 [RFC8820]. Instead, a specification for such an application can use 514 one of the following strategies: 516 * Register a Well-Known URI [WELL-KNOWN-URI] as an entry point for 517 that application. This provides a fixed path on every potential 518 server that will not collide with other applications. 520 * Enable the server authority to convey a URI Template 521 [URI-TEMPLATE] or similar mechanism for generating a URL for an 522 entry point. For example, this might be done in a configuration 523 document or other artefact. 525 Once the discovery document is located, it can be fetched, cached for 526 later reuse (if allowed by its metadata), and used to locate other 527 resources that are relevant to the application, using full URIs or 528 URL Templates. 530 In some cases, an application may not wish to use such a discovery 531 document; for example, when communication is very brief, or when the 532 latency concerns of doing so precludes the use of a discovery 533 document. These situations can be addressed by placing all of the 534 application's resources under a well-known location. 536 4.4.2. Considering URI Schemes 538 Applications that use HTTP will typically employ the "http" and/or 539 "https" URI schemes. "https" is RECOMMENDED to provide 540 authentication, integrity and confidentiality, as well as mitigate 541 pervasive monitoring attacks [RFC7258]. 543 However, application-specific schemes can also be defined. When 544 defining an URI scheme for an application using HTTP, there are a 545 number of tradeoffs and caveats to keep in mind: 547 * Unmodified Web browsers will not support the new scheme. While it 548 is possible to register new URI schemes with Web browsers (e.g. 549 registerProtocolHandler() in [HTML], as well as several 550 proprietary approaches), support for these mechanisms is not 551 shared by all browsers, and their capabilities vary. 553 * Existing non-browser clients, intermediaries, servers and 554 associated software will not recognise the new scheme. For 555 example, a client library might fail to dispatch the request; a 556 cache might refuse to store the response, and a proxy might fail 557 to forward the request. 559 * Because URLs occur in HTTP artefacts commonly, often being 560 generated automatically (e.g., in the "Location" response header 561 field), it can be difficult to assure that the new scheme is used 562 consistently. 564 * The resources identified by the new scheme will still be available 565 using "http" and/or "https" URLs. Those URLs can "leak" into use, 566 which can present security and operability issues. For example, 567 using a new scheme to assure that requests don't get sent to a 568 "normal" Web site is likely to fail. 570 * Features that rely upon the URL's origin [RFC6454], such as the 571 Web's same-origin policy, will be impacted by a change of scheme. 573 * HTTP-specific features such as cookies [COOKIES], authentication 574 [HTTP], caching [HTTP-CACHING], HSTS [RFC6797], and CORS [FETCH] 575 might or might not work correctly, depending on how they are 576 defined and implemented. Generally, they are designed and 577 implemented with an assumption that the URL will always be "http" 578 or "https". 580 * Web features that require a secure context [SECCTXT] will likely 581 treat a new scheme as insecure. 583 See [RFC7595] for more information about minting new URI schemes. 585 4.4.3. Transport Ports 587 Applications can use the applicable default port (80 for HTTP, 443 588 for HTTPS), or they can be deployed upon other ports. This decision 589 can be made at deployment time, or might be encouraged by the 590 application's specification (e.g., by registering a port for that 591 application). 593 If a non-default port is used, it needs to be reflected in the 594 authority of all URLs for that resource; the only mechanism for 595 changing a default port is changing the URI scheme (see 596 Section 4.4.2). 598 Using a port other than the default has privacy implications (i.e., 599 the protocol can now be distinguished from other traffic), as well as 600 operability concerns (as some networks might block or otherwise 601 interfere with it). Privacy implications (including those stemming 602 from this distinguishability) should be documented in Security 603 Considerations. 605 See [RFC7605] for further guidance. 607 4.5. Using HTTP Methods 609 Applications that use HTTP MUST confine themselves to using 610 registered HTTP methods such as GET, POST, PUT, DELETE, and PATCH. 612 New HTTP methods are rare; they are required to be registered in the 613 HTTP Method Registry with IETF Review (see [HTTP]), and are also 614 required to be generic. That means that they need to be potentially 615 applicable to all resources, not just those of one application. 617 While historically some applications (e.g., [RFC4791]) have defined 618 non-generic methods, [HTTP] now forbids this. 620 When authors believe that a new method is required, they are 621 encouraged to engage with the HTTP community early (e.g., on the 622 ietf-http-wg@w3.org mailing list), and document their proposal as a 623 separate HTTP extension, rather than as part of an application's 624 specification. 626 4.5.1. GET 628 GET is the most common and useful HTTP method; its retrieval 629 semantics allow caching, side-effect free linking and underlies many 630 of the benefits of using HTTP. 632 Queries can be performed with GET, often using the query component of 633 the URL; this is a familiar pattern from Web browsing, and the 634 results can be cached, improving efficiency of an often expensive 635 process. In some cases, however, GET might be unwieldy for 636 expressing queries, because of the limited syntax of the URI; in 637 particular, if binary data forms part of the query terms, it needs to 638 be encoded to conform to URI syntax. 640 While this is not an issue for short queries, it can become one for 641 larger query terms, or ones which need to sustain a high rate of 642 requests. Additionally, some HTTP implementations limit the size of 643 URLs they support -- although modern HTTP software has much more 644 generous limits than previously (typically, considerably more than 645 8000 octets, as required by [HTTP]). 647 In these cases, an application using HTTP might consider using POST 648 to express queries in the request's content; doing so avoids encoding 649 overhead and URL length limits in implementations. However, in doing 650 so it should be noted that the benefits of GET such as caching and 651 linking to query results are lost. Therefore, applications using 652 HTTP that feel a need to allow POST queries ought to consider 653 allowing both methods. 655 Processing of GET requests should not change application state or 656 have other side effects that might be significant to the client, 657 since implementations can and do retry HTTP GET requests that fail, 658 and some GET requests protected by TLS Early Data might be vulnerable 659 to replay attacks (see [RFC8470]). Note that this does not include 660 logging and similar functions; see [HTTP], Section 9.2.1. 662 Finally, note that while the generic HTTP syntax allows a GET request 663 message to contain content, the purpose is to allow message parsers 664 to be generic; as per [HTTP], Section 9.3.1, content on a GET is not 665 recommended, has no meaning, and will be either ignored or rejected 666 by generic HTTP software (such as intermediaries, caches, servers, 667 and client libraries). 669 4.5.2. OPTIONS 671 The OPTIONS method was defined for metadata retrieval, and is used 672 both by WebDAV [RFC4918] and CORS [FETCH]. Because HTTP-based APIs 673 often need to retrieve metadata about resources, it is often 674 considered for their use. 676 However, OPTIONS does have significant limitations: 678 * It isn't possible to link to the metadata with a simple URL, 679 because OPTIONS is not the default method. 681 * OPTIONS responses are not cacheable, because HTTP caches operate 682 on representations of the resource (i.e., GET and HEAD). If 683 OPTIONS responses are cached separately, their interaction with 684 HTTP cache expiry, secondary keys and other mechanisms needs to be 685 considered. 687 * OPTIONS is "chatty" - always separating metadata out into a 688 separate request increases the number of requests needed to 689 interact with the application. 691 * Implementation support for OPTIONS is not universal; some servers 692 do not expose the ability to respond to OPTIONS requests without 693 significant effort. 695 Instead of OPTIONS, one of these alternative approaches might be more 696 appropriate: 698 * For server-wide metadata, create a well-known URI 699 [WELL-KNOWN-URI], or use an already existing one if appropriate 700 (e.g., HostMeta [RFC6415]). 702 * For metadata about a specific resource, create a separate resource 703 and link to it using a Link response header field or a link 704 serialised into the response's content. See [WEB-LINKING]. Note 705 that the Link header field is available on HEAD responses, which 706 is useful if the client wants to discover a resource's 707 capabilities before they interact with it. 709 4.6. Using HTTP Status Codes 711 HTTP status codes convey semantics both for the benefit of generic 712 HTTP components -- such as caches, intermediaries, and clients -- and 713 applications themselves. However, applications can encounter a 714 number of pitfalls in their use. 716 First, status codes are often generated by components other than the 717 application itself. This can happen, for example, when network 718 errors are encountered, a captive portal, proxy or Content Delivery 719 Network is present, when a server is overloaded, or it thinks it is 720 under attack. They can even be generated by generic client software 721 when certain error conditions are encountered. As a result, if an 722 application assigns specific semantics to one of these status codes, 723 a client can be misled about its state, because the status code was 724 generated by a generic component, not the application itself. 726 Furthermore, mapping application errors to individual HTTP status 727 codes one-to-one often leads to a situation where the finite space of 728 applicable HTTP status codes is exhausted. This, in turn, leads to a 729 number of bad practices -- including minting new, application- 730 specific status codes, or using existing status codes even though the 731 link between their semantics and the application's is tenuous at 732 best. 734 Instead, applications using HTTP should define their errors to use 735 the most applicable status code, making generous use of the general 736 status codes (200, 400 and 500) when in doubt. Importantly, they 737 should not specify a one-to-one relationship between status codes and 738 application errors, thereby avoiding the exhaustion issue outlined 739 above. 741 To distinguish between multiple error conditions that are mapped to 742 the same status code, and to avoid the misattribution issue outlined 743 above, applications using HTTP should convey finer-grained error 744 information in the response's message content and/or header fields. 745 [PROBLEM-DETAILS] provides one way to do so. 747 Because the set of registered HTTP status codes can expand, 748 applications using HTTP should explicitly point out that clients 749 ought to be able to handle all applicable status codes gracefully 750 (i.e., falling back to the generic "n00" semantics of a given status 751 code; e.g., "499" can be safely handled as "400" by clients that 752 don't recognise it). This is preferable to creating a "laundry list" 753 of potential status codes, since such a list won't be complete in the 754 foreseeable future. 756 Applications using HTTP MUST NOT re-specify the semantics of HTTP 757 status codes, even if it is only by copying their definition. It is 758 NOT RECOMMENDED they require specific reason phrases to be used; the 759 reason phrase has no function in HTTP, is not guaranteed to be 760 preserved by implementations, and is not carried at all in the HTTP/2 761 HTTP2 message format. 763 Applications MUST only use registered HTTP status codes. As with 764 methods, new HTTP status codes are rare, and required (by [HTTP]) to 765 be registered with IETF Review. Similarly, HTTP status codes are 766 generic; they are required (by [HTTP]) to be potentially applicable 767 to all resources, not just to those of one application. 769 When authors believe that a new status code is required, they are 770 encouraged to engage with the HTTP community early (e.g., on the 771 ietf-http-wg@w3.org mailing list), and document their proposal as a 772 separate HTTP extension, rather than as part of an application's 773 specification. 775 4.6.1. Redirection 777 The 3xx series of status codes specified in Section 15.4 of [HTTP] 778 direct the user agent to another resource to satisfy the request. 779 The most common of these are 301, 302, 307 and 308, all of which use 780 the Location response header field to indicate where the client 781 should resend the request. 783 There are two ways that the members of this group of status codes 784 differ: 786 * Whether they are permanent or temporary. Permanent redirects can 787 be used to update links stored in the client (e.g., bookmarks), 788 whereas temporary ones cannot. Note that this has no effect on 789 HTTP caching; it is completely separate. 791 * Whether they allow the redirected request to change the request 792 method from POST to GET. Web browsers generally do change POST to 793 GET for 301 and 302; therefore, 308 and 307 were created to allow 794 redirection without changing the method. 796 This table summarises their relationships: 798 +=============================+===========+===========+ 799 | | Permanent | Temporary | 800 +=============================+===========+===========+ 801 | Allows changing the request | 301 | 302 | 802 | method from POST to GET | | | 803 +-----------------------------+-----------+-----------+ 804 | Does not allow changing the | 308 | 307 | 805 | request method | | | 806 +-----------------------------+-----------+-----------+ 808 Table 1 810 The 303 See Other status code can be used to inform the client that 811 the result of an operation is available at a different location using 812 GET. 814 As noted in [HTTP], a user agent is allowed to automatically follow a 815 3xx redirect that has a Location response header field, even if they 816 don't understand the semantics of the specific status code. However, 817 they aren't required to do so; therefore, if an application using 818 HTTP desires redirects to be automatically followed, it needs to 819 explicitly specify the circumstances when this is required. 821 Redirects can be cached (when appropriate cache directives are 822 present), but beyond that they are not 'sticky' -- i.e., redirection 823 of a URI will not result in the client assuming that similar URIs 824 (e.g., with different query parameters) will also be redirected. 826 Applications using HTTP are encouraged to specify that 301 and 302 827 responses change the subsequent request method from POST (but no 828 other method) to GET, to be compatible with browsers. Generally, 829 when a redirected request is made, its header fields are copied from 830 the original request's. However, they can be modified by various 831 mechanisms; e.g., sent Authorization ([HTTP], Section 11) and Cookie 832 ([COOKIES]) header fields will change if the origin (and sometimes 833 path) of the request changes. An application using HTTP should 834 specify if any request header fields that it defines need to be 835 modified or removed upon a redirect; however, this behaviour cannot 836 be relied upon, since a generic client (like a browser) will be 837 unaware of such requirements. 839 4.7. Specifying HTTP Header Fields 841 Applications often define new HTTP header fields. Typically, using 842 HTTP header fields is appropriate in a few different situations: 844 * The field is useful to intermediaries (who often wish to avoid 845 parsing message content), and/or 847 * The field is useful to generic HTTP software (e.g., clients, 848 servers), and/or 850 * It is not possible to include their values in the message content 851 (usually because a format does not allow it). 853 When the conditions above are not met, it is usually better to convey 854 application-specific information in other places; e.g., the message 855 content or the URL query string. 857 New header fields MUST be registered, as per Section 16.3 of [HTTP]. 859 See Section 16.3.2 of [HTTP] for guidelines to consider when minting 860 new header fields. [STRUCTURED-FIELDS] provides a common structure 861 for new header fields, and avoids many issues in their parsing and 862 handling; it is RECOMMENDED that new header fields use it. 864 It is RECOMMENDED that header field names be short (even when field 865 compression is used, there is an overhead) but appropriately 866 specific. In particular, if a header field is specific to an 867 application, an identifier for that application can form a prefix to 868 the header field name, separated by a "-". 870 For example, if the "example" application needs to create three 871 header fields, they might be called "example-foo", "example-bar" and 872 "example-baz". Note that the primary motivation here is to avoid 873 consuming more generic field names, not to reserve a portion of the 874 namespace for the application; see [RFC6648] for related 875 considerations. 877 The semantics of existing HTTP header fields MUST NOT be re-defined 878 without updating their registration or defining an extension to them 879 (if allowed). For example, an application using HTTP cannot specify 880 that the "Location" header field has a special meaning in a certain 881 context. 883 See Section 4.9 for the interaction between header fields and HTTP 884 caching; in particular, request header fields that are used to 885 "select" a response have impact there, and need to be carefully 886 considered. 888 See Section 4.10 for considerations regarding header fields that 889 carry application state (e.g., Cookie). 891 4.8. Defining Message Content 893 Common syntactic conventions for message contents include JSON 894 [JSON], XML [XML], and CBOR [RFC8949]. Best practices for their use 895 are out of scope for this document. 897 Applications should register distinct media types for each format 898 they define; this makes it possible to identify them unambiguously 899 and negotiate for their use. See [RFC6838] for more information. 901 4.9. Leveraging HTTP Caching 903 HTTP caching [HTTP-CACHING] is one of the primary benefits of using 904 HTTP for applications; it provides scalability, reduces latency and 905 improves reliability. Furthermore, HTTP caches are readily available 906 in browsers and other clients, networks as forward and reverse 907 proxies, Content Delivery Networks and as part of server software. 909 Even when an application using HTTP isn't designed to take advantage 910 of caching, it needs to consider how caches will handle its 911 responses, to preserve correct behaviour when one is interposed 912 (whether in the network, server, client, or intervening 913 infrastructure). 915 4.9.1. Freshness 917 Assigning even a short freshness lifetime ([HTTP-CACHING], 918 Section 4.2) -- e.g., 5 seconds -- allows a response to be reused to 919 satisfy multiple clients, and/or a single client making the same 920 request repeatedly. In general, if it is safe to reuse something, 921 consider assigning a freshness lifetime. 923 The most common method for specifying freshness is the max-age 924 response directive ([HTTP-CACHING], Section 5.2.2.1). The Expires 925 header field ([HTTP-CACHING], Section 5.3) can also be used, but it 926 is not necessary; all modern cache implementations support Cache- 927 Control, and specifying freshness as a delta is usually more 928 convenient and less error-prone. 930 It is not necessary to add the "public" response directive 931 ([HTTP-CACHING], Section 5.2.2.9) to cache most responses; it is only 932 necessary when it's desirable to store an authenticated response, or 933 when the status code isn't understood by the cache and there isn't 934 explicit freshness information available. 936 In some situations, responses without explicit cache freshness 937 directives will be stored and served using a heuristic freshness 938 lifetime; see [HTTP-CACHING], Section 4.2.2. As the heuristic is not 939 under control of the application, it is generally preferable to set 940 an explicit freshness lifetime, or make the response explicitly 941 uncacheable. 943 If caching of a response is not desired, the appropriate response 944 directive is "Cache-Control: no-store". Other directives are not 945 necessary, and no-store only need be sent in situations where the 946 response might be cached; see [HTTP-CACHING], Section 3. Note that 947 "Cache-Control: no-cache" allows a response to be stored, just not 948 reused by a cache without validation; it does not prevent caching 949 (despite its name). 951 For example, this response cannot be stored or reused by a cache: 953 HTTP/1.1 200 OK 954 Content-Type: application/example+xml 955 Cache-Control: no-store 957 [content] 959 4.9.2. Stale Responses 961 Authors should understand that stale responses (e.g., with "Cache- 962 Control: max-age=0") can be reused by caches when disconnected from 963 the origin server; this can be useful for handling network issues. 965 If doing so is not suitable for a given response, the origin should 966 use "Cache-Control: must-revalidate". See Section 4.2.4 of 967 [HTTP-CACHING], and also [RFC5861] for additional controls over stale 968 content. 970 Stale responses can be refreshed by assigning a validator, saving 971 both transfer bandwidth and latency for large responses; see 972 Section 13 of [HTTP]. 974 4.9.3. Caching and Application Semantics 976 When an application has a need to express a lifetime that's separate 977 from the freshness lifetime, this should be conveyed separately, 978 either in the response's content or in a separate header field. When 979 this happens, the relationship between HTTP caching and that lifetime 980 needs to be carefully considered, since the response will be used as 981 long as it is considered fresh. 983 In particular, application authors need to consider how responses 984 that are not freshly obtained from the origin server should be 985 handled; if they have a concept like a validity period, this will 986 need to be calculated considering the age of the response (see 987 [HTTP-CACHING], Section 4.2.3). 989 One way to address this is to explicitly specify that responses need 990 to be fresh upon use. 992 4.9.4. Varying Content Based Upon the Request 994 If an application uses a request header field to change the 995 response's header fields or content, authors should point out that 996 this has implications for caching; in general, such resources need to 997 either make their responses uncacheable (e.g., with the "no-store" 998 cache-control directive defined in [HTTP-CACHING], Section 5.2.2.5) 999 or send the Vary response header field ([HTTP], Section 12.5.5) on 1000 all responses from that resource (including the "default" response). 1002 For example, this response: 1004 HTTP/1.1 200 OK 1005 Content-Type: application/example+xml 1006 Cache-Control: max-age=60 1007 ETag: "sa0f8wf20fs0f" 1008 Vary: Accept-Encoding 1010 [content] 1012 can be stored for 60 seconds by both private and shared caches, can 1013 be revalidated with If-None-Match, and varies on the Accept-Encoding 1014 request header field. 1016 4.10. Handling Application State 1018 Applications can use stateful cookies [COOKIES] to identify a client 1019 and/or store client-specific data to contextualise requests. 1021 When used, it is important to carefully specify the scoping and use 1022 of cookies; if the application exposes sensitive data or capabilities 1023 (e.g., by acting as an ambient authority), exploits are possible. 1024 Mitigations include using a request-specific token to assure the 1025 intent of the client. 1027 4.11. Making Multiple Requests 1029 Clients often need to send multiple requests to perform a task. 1031 In HTTP/1 [HTTP11], parallel requests are most often supported by 1032 opening multiple connections. Application performance can be 1033 impacted when too many simultaneous connections are used, because 1034 connections' congestion control will not be coordinated. 1035 Furthermore, it can be difficult for applications to decide when to 1036 issue and which connection to use for a given request, further 1037 impacting performance. 1039 HTTP/2 [HTTP2] and HTTP/3 [HTTP3] offer multiplexing to applications, 1040 removing the need to use multiple connections. However, application 1041 performance can still be significantly affected by how the server 1042 chooses to prioritize responses. Depending on the application, it 1043 might be best for the server to determine the priority of responses, 1044 or for the client to hint its priorities to the server (see, e.g., 1045 [HTTP-PRIORITY]). 1047 In all versions of HTTP, requests are made independently -- you can't 1048 rely on the relative order of two requests to guarantee processing 1049 order. This is because they might be sent over a multiplexed 1050 protocol by an intermediary, sent to different origin servers, or the 1051 server might even perform processing in a different order. If two 1052 requests need strict ordering, the only reliable way to assure the 1053 outcome is to issue the second request when the final response to the 1054 first has begun. 1056 Applications MUST NOT make assumptions about the relationship between 1057 separate requests on a single transport connection; doing so breaks 1058 many of the assumptions of HTTP as a stateless protocol, and will 1059 cause problems in interoperability, security, operability and 1060 evolution. 1062 4.12. Client Authentication 1064 Applications can use HTTP authentication Section 11 of [HTTP] to 1065 identify clients. As per [RFC7617], the Basic authentication scheme 1066 is not suitable for protecting sensitive or valuable information 1067 unless the channel is secure (e.g., using the "HTTPS" URI scheme). 1068 Likewise, [RFC7616] requires the Digest authentication scheme to be 1069 used over a secure channel. 1071 With HTTPS, clients might also be authenticated using certificates 1072 [RFC8446], but note that such authentication is intrinsically scoped 1073 to the underlying transport connection. As a result, a client has no 1074 way of knowing whether the authenticated status was used in preparing 1075 the response (though "Vary: *" and/or "Cache-Control: private" can 1076 provide a partial indication), and the only way to obtain a 1077 specifically unauthenticated response is to open a new connection. 1079 When used, it is important to carefully specify the scoping and use 1080 of authentication; if the application exposes sensitive data or 1081 capabilities (e.g., by acting as an ambient authority; see 1082 Section 8.3 of [RFC6454]), exploits are possible. Mitigations 1083 include using a request-specific token to assure the intent of the 1084 client. 1086 4.13. Co-Existing with Web Browsing 1088 Even if there is not an intent for an application to be used with a 1089 Web browser, its resources will remain available to browsers and 1090 other HTTP clients. This means that all such applications that use 1091 HTTP need to consider how browsers will interact with them, 1092 particularly regarding security. 1094 For example, if an application's state can be changed using a POST 1095 request, a Web browser can easily be coaxed into cross-site request 1096 forgery (CSRF) from arbitrary Web sites. 1098 Or, if an attacker gains control of content returned from the 1099 application's resources (for example, part of the request is 1100 reflected in the response, or the response contains external 1101 information that the attacker can change), they can inject code into 1102 the browser and access data and capabilities as if they were the 1103 origin -- a technique known as a cross-site scripting (XSS) attack. 1105 This is only a small sample of the kinds of issues that applications 1106 using HTTP must consider. Generally, the best approach is to 1107 actually consider the application as a Web application, and to follow 1108 best practices for their secure development. 1110 A complete enumeration of such practices is out of scope for this 1111 document, but some considerations include: 1113 * Using an application-specific media type in the Content-Type 1114 header field, and requiring clients to fail if it is not used. 1116 * Using X-Content-Type-Options: nosniff [FETCH] to assure that 1117 content under attacker control can't be coaxed into a form that is 1118 interpreted as active content by a Web browser. 1120 * Using Content-Security-Policy [CSP] to constrain the capabilities 1121 of active content (i.e., that which can execute scripts, such as 1122 HTML [HTML] and PDF), thereby mitigating Cross-Site Scripting 1123 attacks. 1125 * Using Referrer-Policy [REFERRER-POLICY] to prevent sensitive data 1126 in URLs from being leaked in the Referer request header field. 1128 * Using the 'HttpOnly' flag on Cookies to assure that cookies are 1129 not exposed to browser scripting languages [COOKIES]. 1131 * Avoiding use of compression on any sensitive information (e.g., 1132 authentication tokens, passwords), as the scripting environment 1133 offered by Web browsers allows an attacker to repeatedly probe the 1134 compression space; if the attacker has access to the path of the 1135 communication, they can use this capability to recover that 1136 information. 1138 Depending on how they are intended to be deployed, specifications for 1139 applications using HTTP might require the use of these mechanisms in 1140 specific ways, or might merely point them out in Security 1141 Considerations. 1143 An example of a HTTP response from an application that does not 1144 intend for its content to be treated as active by browsers might look 1145 like this: 1147 HTTP/1.1 200 OK 1148 Content-Type: application/example+json 1149 X-Content-Type-Options: nosniff 1150 Content-Security-Policy: default-src 'none' 1151 Cache-Control: max-age=3600 1152 Referrer-Policy: no-referrer 1154 [content] 1156 If an application has browser compatibility as a goal, client 1157 interaction ought to be defined in terms of [FETCH], since that is 1158 the abstraction that browsers use for HTTP; it enforces many of these 1159 best practices. 1161 4.14. Maintaining Application Boundaries 1163 Because many HTTP capabilities are scoped to the origin [RFC6454], 1164 applications also need to consider how deployments might interact 1165 with other applications (including Web browsing) on the same origin. 1167 For example, if Cookies [COOKIES] are used to carry application 1168 state, they will be sent with all requests to the origin by default 1169 (unless scoped by path), and the application might receive cookies 1170 from other applications on the origin. This can lead to security 1171 issues, as well as collision in cookie names. 1173 One solution to these issues is to require a dedicated hostname for 1174 the application, so that it has a unique origin. However, it is 1175 often desirable to allow multiple applications to be deployed on a 1176 single hostname; doing so provides the most deployment flexibility 1177 and enables them to be "mixed" together (See [RFC8820] for details). 1178 Therefore, applications using HTTP should strive to allow multiple 1179 applications on an origin. 1181 To enable this, when specifying the use of Cookies, HTTP 1182 authentication realms [HTTP], or other origin-wide HTTP mechanisms, 1183 applications using HTTP should not mandate the use of a particular 1184 name, but instead let deployments configure them. Consideration 1185 should be given to scoping them to part of the origin, using their 1186 specified mechanisms for doing so. 1188 Modern Web browsers constrain the ability of content from one origin 1189 to access resources from another, to avoid leaking private 1190 information. As a result, applications that wish to expose cross- 1191 origin data to browsers will need to implement the CORS protocol; see 1192 [FETCH]. 1194 4.15. Using Server Push 1196 HTTP/2 added the ability for servers to "push" request/response pairs 1197 to clients in [HTTP2], Section 8.4. While server push seems like a 1198 natural fit for many common application semantics (e.g., "fanout" and 1199 publish/subscribe), a few caveats should be noted: 1201 * Server push is hop-by-hop; that is, it is not automatically 1202 forwarded by intermediaries. As a result, it might not work 1203 easily (or at all) with proxies, reverse proxies, and Content 1204 Delivery Networks. 1206 * Server push can have negative performance impact on HTTP when used 1207 incorrectly; in particular, if there is contention with resources 1208 that have actually been requested by the client. 1210 * Server push is implemented differently in different clients, 1211 especially regarding interaction with HTTP caching, and 1212 capabilities might vary. 1214 * APIs for server push are currently unavailable in some 1215 implementations, and vary widely in others. In particular, there 1216 is no current browser API for it. 1218 * Server push is not supported in HTTP/1.1 or HTTP/1.0. 1220 * Server push does not form part of the "core" semantics of HTTP, 1221 and therefore might not be supported by future versions of the 1222 protocol. 1224 Applications wishing to optimise cases where the client can perform 1225 work related to requests before the full response is available (e.g., 1226 fetching links for things likely to be contained within) might 1227 benefit from using the 103 (Early Hints) status code; see [RFC8297]. 1229 Applications using server push directly need to enforce the 1230 requirements regarding authority in [HTTP2], Section 8.4, to avoid 1231 cross-origin push attacks. 1233 4.16. Allowing Versioning and Evolution 1235 It's often necessary to introduce new features into application 1236 protocols, and change existing ones. 1238 In HTTP, backwards-incompatible changes can be made using mechanisms 1239 such as: 1241 * Using a distinct link relation type [WEB-LINKING] to identify a 1242 URL for a resource that implements the new functionality. 1244 * Using a distinct media type [RFC6838] to identify formats that 1245 enable the new functionality. 1247 * Using a distinct HTTP header field to implement new functionality 1248 outside the message content. 1250 5. IANA Considerations 1252 This document has no requirements for IANA. 1254 6. Security Considerations 1256 Applications using HTTP are subject to the security considerations of 1257 HTTP itself and any extensions used; [HTTP], [HTTP-CACHING], and 1258 [WEB-LINKING] are often relevant, amongst others. 1260 Section 4.4.2 recommends support for 'https' URLs, and discourages 1261 the use of 'http' URLs, to provide authentication, integrity and 1262 confidentiality, as well as mitigate pervasive monitoring attacks. 1263 Many applications using HTTP perform authentication and authorization 1264 with bearer tokens (e.g., in session cookies). If the transport is 1265 unencrypted, an attacker that can eavesdrop upon or modify HTTP 1266 communications can often escalate their privilege to perform 1267 operations on resources. 1269 Section 4.9.3 highlights the potential for mismatch between HTTP 1270 caching and application-specific storage of responses or information 1271 therein. 1273 Section 4.10 discusses the impact of using stateful mechanisms in the 1274 protocol as ambient authority, and suggests a mitigation. 1276 Section 4.13 highlights the implications of Web browsers' 1277 capabilities on applications that use HTTP. 1279 Section 4.14 discusses the issues that arise when applications are 1280 deployed on the same origin as Web sites (and other applications). 1282 Section 4.15 highlights risks of using HTTP/2 server push in a manner 1283 other than specified. 1285 Applications that use HTTP in a manner that involves modification of 1286 implementations -- for example, requiring support for a new URI 1287 scheme, or a non-standard method -- risk having those implementations 1288 "fork" from their parent HTTP implementations, with the possible 1289 result that they do not benefit from patches and other security 1290 improvements incorporated upstream. 1292 6.1. Privacy Considerations 1294 HTTP clients can expose a variety of information to servers. Besides 1295 information that's explicitly sent as part of an application's 1296 operation (for example, names and other user-entered data), and "on 1297 the wire" (which is one of the reasons https is recommended in 1298 Section 4.4.2), other information can be gathered through less 1299 obvious means -- often by connecting activities of a user over time. 1301 This includes session information, tracking the client through 1302 fingerprinting, and code execution. 1304 Session information includes things like the IP address of the 1305 client, TLS session tickets, Cookies, ETags stored in the client's 1306 cache, and other stateful mechanisms. Applications are advised to 1307 avoid using session mechanisms unless they are unavoidable or 1308 necessary for operation, in which case these risks needs to be 1309 documented. When they are used, implementations should be encouraged 1310 to allow clearing such state. 1312 Fingerprinting uses unique aspects of a client's messages and 1313 behaviours to connect disparate requests and connections. For 1314 example, the User-Agent request header field conveys specific 1315 information about the implementation; the Accept-Language request 1316 header field conveys the users' preferred language. In combination, 1317 a number of these markers can be used to uniquely identify a client, 1318 impacting its control over its data. As a result, applications are 1319 advised to specify that clients should only emit the information they 1320 need to function in requests. 1322 Finally, if an application exposes the ability to execute code, great 1323 care needs to be taken, since any ability to observe its environment 1324 can be used as an opportunity to both fingerprint the client and to 1325 obtain and manipulate private data (including session information). 1326 For example, access to high-resolution timers (even indirectly) can 1327 be used to profile the underlying hardware, creating a unique 1328 identifier for the system. Applications are advised to avoid 1329 allowing the use of mobile code where possible; when it cannot be 1330 avoided, the resulting system's security properties need be carefully 1331 scrutinised. 1333 7. References 1335 7.1. Normative References 1337 [HTTP] Fielding, R. T., Nottingham, M., and J. Reschke, "HTTP 1338 Semantics", Work in Progress, Internet-Draft, draft-ietf- 1339 httpbis-semantics-18, 18 August 2021, 1340 . 1343 [HTTP-CACHING] 1344 Fielding, R. T., Nottingham, M., and J. Reschke, "HTTP 1345 Caching", Work in Progress, Internet-Draft, draft-ietf- 1346 httpbis-cache-18, 18 August 2021, 1347 . 1350 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 1351 Requirement Levels", BCP 14, RFC 2119, 1352 DOI 10.17487/RFC2119, March 1997, 1353 . 1355 [RFC6454] Barth, A., "The Web Origin Concept", RFC 6454, 1356 DOI 10.17487/RFC6454, December 2011, 1357 . 1359 [RFC6648] Saint-Andre, P., Crocker, D., and M. Nottingham, 1360 "Deprecating the "X-" Prefix and Similar Constructs in 1361 Application Protocols", BCP 178, RFC 6648, 1362 DOI 10.17487/RFC6648, June 2012, 1363 . 1365 [RFC6838] Freed, N., Klensin, J., and T. Hansen, "Media Type 1366 Specifications and Registration Procedures", BCP 13, 1367 RFC 6838, DOI 10.17487/RFC6838, January 2013, 1368 . 1370 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 1371 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 1372 May 2017, . 1374 [RFC8820] Nottingham, M., "URI Design and Ownership", BCP 190, 1375 RFC 8820, DOI 10.17487/RFC8820, June 2020, 1376 . 1378 [URL] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 1379 Resource Identifier (URI): Generic Syntax", STD 66, 1380 RFC 3986, DOI 10.17487/RFC3986, January 2005, 1381 . 1383 [WEB-LINKING] 1384 Nottingham, M., "Web Linking", RFC 8288, 1385 DOI 10.17487/RFC8288, October 2017, 1386 . 1388 [WELL-KNOWN-URI] 1389 Nottingham, M., "Well-Known Uniform Resource Identifiers 1390 (URIs)", RFC 8615, DOI 10.17487/RFC8615, May 2019, 1391 . 1393 7.2. Informative References 1395 [COOKIES] Barth, A., "HTTP State Management Mechanism", RFC 6265, 1396 DOI 10.17487/RFC6265, April 2011, 1397 . 1399 [CSP] West, M., "Content Security Policy Level 3", World Wide 1400 Web Consortium WD WD-CSP3-20160913, 13 September 2016, 1401 . 1403 [FETCH] WHATWG, "Fetch - Living Standard", n.d., 1404 . 1406 [HTML] WHATWG, "HTML - Living Standard", n.d., 1407 . 1409 [HTTP-PRIORITY] 1410 Oku, K. and L. Pardue, "Extensible Prioritization Scheme 1411 for HTTP", Work in Progress, Internet-Draft, draft-ietf- 1412 httpbis-priority-04, 11 July 2021, 1413 . 1416 [HTTP11] Fielding, R. T., Nottingham, M., and J. Reschke, 1417 "HTTP/1.1", Work in Progress, Internet-Draft, draft-ietf- 1418 httpbis-messaging-18, 18 August 2021, 1419 . 1422 [HTTP2] Thomson, M. and C. Benfield, "Hypertext Transfer Protocol 1423 Version 2 (HTTP/2)", Work in Progress, Internet-Draft, 1424 draft-ietf-httpbis-http2bis-03, 12 July 2021, 1425 . 1428 [HTTP3] Bishop, M., "Hypertext Transfer Protocol Version 3 1429 (HTTP/3)", Work in Progress, Internet-Draft, draft-ietf- 1430 quic-http-34, 2 February 2021, 1431 . 1434 [JSON] Bray, T., Ed., "The JavaScript Object Notation (JSON) Data 1435 Interchange Format", STD 90, RFC 8259, 1436 DOI 10.17487/RFC8259, December 2017, 1437 . 1439 [PROBLEM-DETAILS] 1440 Nottingham, M. and E. Wilde, "Problem Details for HTTP 1441 APIs", RFC 7807, DOI 10.17487/RFC7807, March 2016, 1442 . 1444 [REFERRER-POLICY] 1445 Eisinger, J. and E. Stark, "Referrer Policy", World Wide 1446 Web Consortium CR CR-referrer-policy-20170126, 26 January 1447 2017, 1448 . 1450 [RFC3205] Moore, K., "On the use of HTTP as a Substrate", BCP 56, 1451 RFC 3205, DOI 10.17487/RFC3205, February 2002, 1452 . 1454 [RFC4791] Daboo, C., Desruisseaux, B., and L. Dusseault, 1455 "Calendaring Extensions to WebDAV (CalDAV)", RFC 4791, 1456 DOI 10.17487/RFC4791, March 2007, 1457 . 1459 [RFC4918] Dusseault, L., Ed., "HTTP Extensions for Web Distributed 1460 Authoring and Versioning (WebDAV)", RFC 4918, 1461 DOI 10.17487/RFC4918, June 2007, 1462 . 1464 [RFC5861] Nottingham, M., "HTTP Cache-Control Extensions for Stale 1465 Content", RFC 5861, DOI 10.17487/RFC5861, May 2010, 1466 . 1468 [RFC6415] Hammer-Lahav, E., Ed. and B. Cook, "Web Host Metadata", 1469 RFC 6415, DOI 10.17487/RFC6415, October 2011, 1470 . 1472 [RFC6797] Hodges, J., Jackson, C., and A. Barth, "HTTP Strict 1473 Transport Security (HSTS)", RFC 6797, 1474 DOI 10.17487/RFC6797, November 2012, 1475 . 1477 [RFC7258] Farrell, S. and H. Tschofenig, "Pervasive Monitoring Is an 1478 Attack", BCP 188, RFC 7258, DOI 10.17487/RFC7258, May 1479 2014, . 1481 [RFC7301] Friedl, S., Popov, A., Langley, A., and E. Stephan, 1482 "Transport Layer Security (TLS) Application-Layer Protocol 1483 Negotiation Extension", RFC 7301, DOI 10.17487/RFC7301, 1484 July 2014, . 1486 [RFC7595] Thaler, D., Ed., Hansen, T., and T. Hardie, "Guidelines 1487 and Registration Procedures for URI Schemes", BCP 35, 1488 RFC 7595, DOI 10.17487/RFC7595, June 2015, 1489 . 1491 [RFC7605] Touch, J., "Recommendations on Using Assigned Transport 1492 Port Numbers", BCP 165, RFC 7605, DOI 10.17487/RFC7605, 1493 August 2015, . 1495 [RFC7616] Shekh-Yusef, R., Ed., Ahrens, D., and S. Bremer, "HTTP 1496 Digest Access Authentication", RFC 7616, 1497 DOI 10.17487/RFC7616, September 2015, 1498 . 1500 [RFC7617] Reschke, J., "The 'Basic' HTTP Authentication Scheme", 1501 RFC 7617, DOI 10.17487/RFC7617, September 2015, 1502 . 1504 [RFC8297] Oku, K., "An HTTP Status Code for Indicating Hints", 1505 RFC 8297, DOI 10.17487/RFC8297, December 2017, 1506 . 1508 [RFC8446] Rescorla, E., "The Transport Layer Security (TLS) Protocol 1509 Version 1.3", RFC 8446, DOI 10.17487/RFC8446, August 2018, 1510 . 1512 [RFC8470] Thomson, M., Nottingham, M., and W. Tarreau, "Using Early 1513 Data in HTTP", RFC 8470, DOI 10.17487/RFC8470, September 1514 2018, . 1516 [RFC8949] Bormann, C. and P. Hoffman, "Concise Binary Object 1517 Representation (CBOR)", STD 94, RFC 8949, 1518 DOI 10.17487/RFC8949, December 2020, 1519 . 1521 [SECCTXT] West, M., "Secure Contexts", World Wide Web Consortium CR 1522 CR-secure-contexts-20160915, 15 September 2016, 1523 . 1525 [STRUCTURED-FIELDS] 1526 Nottingham, M. and P-H. Kamp, "Structured Field Values for 1527 HTTP", RFC 8941, DOI 10.17487/RFC8941, February 2021, 1528 . 1530 [URI-TEMPLATE] 1531 Gregorio, J., Fielding, R., Hadley, M., Nottingham, M., 1532 and D. Orchard, "URI Template", RFC 6570, 1533 DOI 10.17487/RFC6570, March 2012, 1534 . 1536 [XML] Bray, T., Paoli, J., Sperberg-McQueen, M., Maler, E., and 1537 F. Yergeau, "Extensible Markup Language (XML) 1.0 (Fifth 1538 Edition)", World Wide Web Consortium Recommendation REC- 1539 xml-20081126, 26 November 2008, 1540 . 1542 Appendix A. Changes from RFC 3205 1544 [RFC3205] captured the Best Current Practice in the early 2000's, 1545 based on the concerns facing protocol designers at the time. Use of 1546 HTTP has changed considerably since then, and as a result this 1547 document is substantially different. As a result, the changes are 1548 too numerous to list individually. 1550 Author's Address 1552 Mark Nottingham 1553 Prahran 1554 Australia 1556 Email: mnot@mnot.net 1557 URI: https://www.mnot.net/