@@ -43,14 +43,29 @@ states that for any header field that can appear multiple times, it is exactly
43
43
equivalent to sending that header field only once with all the values joined by
44
44
commas.
45
45
46
- However, RFC 7230 and RFC 6265 make it clear that this rule does not apply to
47
- the various headers used by HTTP cookies (``Cookie `` and ``Set-Cookie ``). The
48
- ``Cookie `` header must only be sent once by a user-agent, but the
49
- ``Set-Cookie `` header may appear repeatedly and cannot be joined by commas.
46
+ However, for HTTP cookies (``Cookie `` and ``Set-Cookie ``) the allowed behaviour
47
+ does not follow the above rule, and also varies slightly based on the HTTP
48
+ protocol version:
49
+
50
+ * For the ``Set-Cookie `` header in HTTP/1.0, HTTP/1.1 and HTTP2.0, it may appear
51
+ repeatedly, but cannot be concatenated by commas (or anything else) into a
52
+ single header field.
53
+
54
+ * For the ``Cookie `` header, in HTTP/1.0 and HTTP/1.1, RFC 7230 and RFC 6265
55
+ make it clear that the ``Cookie `` header must only be sent once by a
56
+ user-agent, and must be concatenated into a single octet string using the
57
+ two-octet delimiter of 0x3b, 0x20 (the ASCII string "; "). However in HTTP/2,
58
+ RFC 9113 states that ``Cookie `` headers MAY appear repeatedly, OR be
59
+ concatenated using the two-octet delimiter of 0x3b, 0x20
60
+ (the ASCII string "; ").
61
+
50
62
The ASGI design decision is to transport both request and response headers as
51
63
lists of 2-element ``[name, value] `` lists and preserve headers exactly as they
52
64
were provided.
53
65
66
+ For ASGI applications that support HTTP/2, care should be taken to handle the
67
+ special case for ``Cookie `` noted above.
68
+
54
69
The HTTP protocol should be signified to ASGI applications with a ``type ``
55
70
value of ``http ``.
56
71
0 commit comments