Description
The context
A sender can send multiple Authorization
headers in a request, because the Authorization
header’s definition, credentials
, allows multiple auth-param
s to be recombined as a comma-separated list.
RFC 9110 — HTTP semantics
a sender MUST NOT generate multiple field lines with the same name in a message (whether in the headers or trailers) or append a field line when a field line of the same name already exists in the message, unless that field's definition allows multiple field line values to be recombined as a comma-separated list (i.e., at least one alternative of the field's definition allows a comma-separated list, such as an ABNF rule of
#(values)
defined in Section 5.6.1).
Authorization = credentials
credentials = auth-scheme [ 1*SP ( token68 / #auth-param ) ]
Node.js MAY join them together with ,
.
RFC 9110 — HTTP semantics
A recipient MAY combine multiple field lines within a field section that have the same field name into one field line, without changing the semantics of the message, by appending each subsequent field line value to the initial field line value in order, separated by a comma ("
,
") and optional whitespace (OWS
, defined in Section 5.6.3). For consistency, usecomma SP
.
Currently, Node.js ignores duplicate Authorization
headers when it creates message.headers
.
Node.js 19.2.0 documentation — HTTP
- Duplicates of
age
,authorization
,content-length
,content-type
,etag
,expires
,from
,host
,if-modified-since
,if-unmodified-since
,last-modified
,location
,max-forwards
,proxy-authorization
,referer
,retry-after
,server
, oruser-agent
are discarded.- …
- For all other headers, the values are joined together with
,
.
Suggestion
I suggest Node.js join the field line values of multiple Authorization
headers in a request with ,
, instead of ignoring them, when it creates message.headers
.