Skip to content

Commit d95e378

Browse files
authored
Clarified Cookie header behaviour in HTTP/2
1 parent 0c7b964 commit d95e378

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

specs/www.rst

+19-4
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,29 @@ states that for any header field that can appear multiple times, it is exactly
4343
equivalent to sending that header field only once with all the values joined by
4444
commas.
4545

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+
5062
The ASGI design decision is to transport both request and response headers as
5163
lists of 2-element ``[name, value]`` lists and preserve headers exactly as they
5264
were provided.
5365

66+
For ASGI applications that support HTTP/2, care should be taken to handle the
67+
special case for ``Cookie`` noted above.
68+
5469
The HTTP protocol should be signified to ASGI applications with a ``type``
5570
value of ``http``.
5671

0 commit comments

Comments
 (0)