Closed fsteeg closed 1 year ago
What about multiple headers? Can Flux accept multiple parameters of the same name? Or would we have to find a different mechanism?
I have an implementation ready for the simple case (single header). Once we decide how to deal with multiple headers, I can open a pull request.
We could use an &
like for query parameters, e.g.:
open-http(header="x-header-1:abc&x-header-2:123")
This is also used for the attributeValuesAsSubfields
option in HtmlDecoder
.
But then you can't set a header with &
in its value. Is this a sufficiently uncommon character to be suitable as separator?
Can Flux accept multiple parameters of the same name?
No, it can't (uses a Map
to collect the named arguments).
But then you can't set a header with & in its value.
We could expect the individual headers header values to be URI-encoded (e.g. %26
for &
).
Hm, we could, but I'm not really sure that's a reasonable assumption. After all, what do header values have to do with URIs?
It would be possible to enable duplicate named arguments in Flux (with Map<String, List<String>>
), but that would be an incompatible change (and has somewhat of a ripple effect).
Maybe we should wait for others to weigh in before we decide?
We could use \n
which is an invalid character (see 80235d6 for a possible implementation).
Requirement from OERSI: provide a way to set custom headers on the HTTP connection, e.g.
x-api-key: 123456780
.We could add a generic
setHeader
option to HttpOpener, used in flux likeopen-http(header="x-api-key: 123456780")
.