Open Norbytus opened 1 month ago
Can you give me an example on this?
Because it works as intended, afaik:
# @name REQUEST_FOOBAR
POST https://httpbin.org/post HTTP/1.1
Date: Foobar
{
"foo": "bonobo",
"foobar": true
}
> {%
client.log(request.headers.findByName("Date").getRawValue());
client.log(response.headers.valuesOf("Date").value);
%}
This outputs:
Foobar
Mon, 14 Oct 2024 01:27:03 GMT
The first one is the header from the request and the second one the header from the response.
Its more i wrote wrong description, For example you have in response or request headers like
HTTP/1.1 200 OK
Cache-Control: no-cache, private
Content-Type: application/json
Set-Cookie: Access-Token=value
Set-Cookie: Refresh-Token=value
Vary: Accept-Encoding
Transfer-Encoding: chunked
When i try get access to header you get last one
response.headers.valuesOf('Set-Cookie')
RFC 2616 says it is possible to send multiple values in separate header lines only when it is possible to also combine the values by comma in one header line. Currently it is not supported in Kulala.
Some implementation always return an array, some will combine these to a comma separated list (which I think is the only solution to have backward compatibility)
In jetbrains it's looks like
response.headers.valuesOf('Set-Cookie').forEach(function (value) {/*... */}
In jetbrains it's looks like
response.headers.valuesOf('Set-Cookie').forEach(function (value) {/*... */}
Will try in jetbrains and see if we can implement it in kulala.
What is the result when there is only one occurrence? A string (so the caller has to check the result type) or an array with one element (that would be a breaking change in scripts).
we need to decide what we do with the Request Variables: vscode-rest-client returns the first one.
As RFC defines all implementations must accept both forms maybe we return the comma list at least in Request Variables.
if you test against JetBrains please also check if they deliver an array if given as list in one header.
I don't use JetBrains, but my college use like this JetBrains doc https://www.jetbrains.com/help/idea/http-response-reference.html#headers-reference
response.headers.valuesOf('Set-Cookie').forEach(function (value) {
const parts = value.split('=');
const settings = parts[1].split(';');
if (parts[0] === 'First_Variant') {
/* ... */
}
if (parts[0] === 'Second_Varoant') {
/* .. */
}
});
If response or request have header with same name, response.headers.valuesOf('Header name') return last header