Reputation: 54992
Node http2 requests look like this:
const client = http2.connect('https://somehost.com')
const req = client.request( {
':path': '/some/path',
':method': 'GET',
'header-name': 'header-value',
'cookie': 'foo=bar'
} )
It doesn't seem possible to send multiple cookie headers like this. Am I missing something? Note that the cookies should not get joined like in http/https headers.
Upvotes: 0
Views: 919
Reputation: 8135
As it is said in doc, duplicate cookie headers separated by ";"
and set-cookie
should be array.
https://nodejs.org/api/http2.html#http2_headers_object
set-cookie is always an array. Duplicates are added to the array. For duplicate cookie headers, the values are joined together with '; '.
const client = http2.connect('https://somehost.com')
const req = client.request( {
':path': '/some/path',
':method': 'GET',
'header-name': 'header-value',
'Set-Cookie': ['ting="tang; expires=0; path=/;"', 'wallawalla="bingbang; expires=123456789; path=/;"'],
} )
Upvotes: 0
Reputation: 1229
So my understanding is that if the client is HTTP/2 then you concatenate cookies with a semicolon like Lawrence said. Which is fine if the server is also HTTP/2, however if the server is HTTP/1.1 there will need to be some extra processing to concatenate them.
If there are multiple Cookie header fields after decompression, these MUST be concatenated into a single octet string using the two-octet delimiter of 0x3B, 0x20 (the ASCII string "; ")
Confirmed by the spec for HTTP2 https://www.rfc-editor.org/rfc/rfc7540#section-8.1.2.5
Upvotes: 0