-
-
Notifications
You must be signed in to change notification settings - Fork 645
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: Redbean's Fetch overwrites multiple Set-Cookie headers #1313
Comments
This has been discussed on discord about a year ago, but there is no obvious solution that is good. Here is the extract from the Discord thread:
I'm open to suggestions. |
Thank you for pointing out that there is a discord server. somehow i missed that source of information. Let’s fixes dont’s:
I’ve come up with two ideas. Set-Cookie header renamingCreate Set-Cookie iterator. During creating headers table push found Set-Cookie with new name (e.g. Set-Cookie1, Set-Cookie2). After processing multiple Set-Cookie change first or last Set-Cookie new name back to original Set-Cookie. It depends on how now populates headers table. This prevents breaking backwards compatibility.
Cons: messing around with not original server headers. CookieJarIn various languages (e.g. java[1], python[2], go[3]) for cookies use concept of cookiejar. Fetch could extends config table with new optional key (e.g. jar, cookiejar). This key holds user defined table and populates it with found values of Set-Cookie headers.
Pros: keep backwards compatibility. [1] https://github.com/rest-assured/rest-assured/wiki/Usage#cookies |
The local s, h, b = Fetch("https://www.google.com")
print(h["Set-Cookie"]) -- old way, backwards compatibility
for index = 1, #h do
local name, value = h[index][1], h[index][2]
if name == "Set-Cookie" then
print(value)
end
end We can also extend this when making a request: Fetch("https://www.google.com", {
headers = {
["Content-Type"] = "text/html", -- old way
{"Set-Cookie", "value1"},
{"Set-Cookie", "value2"}
}
}) I consider this issue a high priority because I had to use another framework due to this problem. |
Contact Details
No response
What happened?
When executing request with Fetch i expect too see multiple values of Set-Cookie header in header's table.
Actually, there is only one value of Set-Cookie header. I suppose it happens because table's keys are uniq.
Version
redbean 3.0.0
What operating system are you seeing the problem on?
No response
Relevant log output
The text was updated successfully, but these errors were encountered: