mirror of
https://github.com/hoppscotch/hoppscotch.git
synced 2026-04-25 16:55:59 +03:00
[PR #5394] [MERGED] fix(relay): multiple Set-Cookie headers in resp #5181
Labels
No labels
CodeDay
a11y
browser limited
bug
bug fix
cli
core
critical
design
desktop
discussion
docker
documentation
duplicate
enterprise
feature
feature
fosshack
future
good first issue
hacktoberfest
help wanted
i18n
invalid
major
minor
need information
need testing
not applicable to hoppscotch
not reproducible
pull-request
question
refactor
resolved
sandbox
self-host
spam
stale
testmu
wip
wont fix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hoppscotch#5181
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/hoppscotch/hoppscotch/pull/5394
Author: @CuriousCorrelation
Created: 9/21/2025
Status: ✅ Merged
Merged: 9/23/2025
Merged by: @jamesgeorge007
Base:
next← Head:relay-fix-multi-value-set-cookie-headers📝 Commits (4)
e139b76fix(relay): multiple Set-Cookie headers in resp1b84e78fix: typos1f12609fix: doc for defensive handling in resp transformbd0a2dfchore: cleanup📊 Changes
8 files changed (+76 additions, -15 deletions)
View changed files
📝
packages/hoppscotch-agent/src-tauri/Cargo.lock(+1 -1)📝
packages/hoppscotch-common/src/helpers/kernel/rest/response.ts(+49 -3)📝
packages/hoppscotch-desktop/plugin-workspace/relay/src/transfer.rs(+16 -1)📝
packages/hoppscotch-desktop/plugin-workspace/tauri-plugin-relay/Cargo.lock(+1 -1)📝
packages/hoppscotch-desktop/src-tauri/Cargo.lock(+2 -2)📝
packages/hoppscotch-desktop/src-tauri/Cargo.toml(+1 -1)📝
packages/hoppscotch-kernel/package.json(+1 -1)📝
pnpm-lock.yaml(+5 -5)📄 Description
This is an experimental way to fix multiple
Set-Cookieheaders beinglost during HTTP response pre/post-processing by concat-ing them with
\nin the networking layer, so all cookies to be displayed in theresponse headers panel instead of only the first one being visible.
NOTE: This is an experimental workaround for the time being.
\nis used here as a separator because HTTP headers are inherentlyline-oriented (
\r\non the wire). This makes it trivial to split backinto distinct
Set-Cookieheaders without violating RFC rules. Thenext idea would be using a custom delimiter but it also would be
arbitrary and risk breaking if that delimiter ever appeared in a cookie
value. The main trade-off is that this is a fragile workaround,
unusual edge cases (e.g. malformed cookies containing newlines, or
components that normalize headers differently) may fail. A full fix
would require changing the header storage structure to support multiple
values per key (the rough idea around that is explained in FE-1008).
Closes FE-1008 (phase-1)
Closes FE-309
Closes #1546 (multiple Set-Cookie headers missing in response display)
Closes #5344 (ignoring one Set-Cookie when response has 2 values)
Closes #5375 (only shows first Set-Cookie when multiple cookies present)
Partially addresses #3532 (fixes header display, automatic cookie
storage will be handled separately).
When servers returned multiple
Set-Cookieheaders, only the firstheader was preserved while subsequent ones were discarded.
The issue occurres because
HashMap<String, String>data structure inTransferHandlercould only store one value per header name (by thevery nature of hashmaps or records for instance).
What's changed
Relay networking layer
The header processing in
transfer.rsnow includes special handlingjust for
set-cookieheaders (case-insensitive accumulator). Whenmultiple Set-Cookie headers are encountered, they are concatenated with
newlines (why is explained above).
FE processing
Added
processHeadersfunction inresponse.tsthatsplits concatenated
Set-Cookieheaders back into separate headerentries.
Dependencies
Updated
relayandtauri-plugin-relayto commits that include theSet-Cookieconcatenation fix across all target packages.Testing
Test with any endpoints that set multiple cookies:
or perhaps use
httpbin:or even a custom server script:
Expected response headers:
In desktop app response headers panel, all three cookies now appear as
separate header entries instead of only the first one being
visible.
Special Note On Backwards Compat
This preserves the existing
HashMap<String, String>structure withoutrequiring changes to the
RelayResponseinterface or frontend headerprocessing pipeline since this will have a rather large ripple effect
all over the codebase. A complete fix is described in FE-1008.
Implementation notes
The comment in
processHeadersshould explain the rationale:The newline concatenation also preserves O(1) header lookup
performance.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.