workers-rs icon indicating copy to clipboard operation
workers-rs copied to clipboard

[BUG] set-cookie twice / header folds

Open ostenbom opened this issue 2 years ago • 1 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

What version of workers-rs are you using?

0.0.18

What version of wrangler are you using?

0.0.18

Describe the bug

When calling a cloudflare worker in workers-rs, the set-cookie header "folds" and creates a single set-cookie = cookie1=value1, cookie2=value2.

According to cloudflare docs and the IETF RFC, the set-cookie header should not fold.

We do not have the same behaviour in our javascript workers.

It's a tricky case when looking at the headers interface, but maybe a similar getAll interface is needed here?

This makes it slightly more tricky to act as a reverse-proxy and forward requests from our worker.

Steps To Reproduce

  1. Make a cf workers-rs worker
  2. Log request.headers
  3. curl -H "Set-Cookie: cookie1=value1" -H "Set-Cookie: cookie2=value2" http://0.0.0.0:8787
  4. Observe set-cookie = cookie1=value1, cookie2=value2

ostenbom avatar Dec 04 '23 14:12 ostenbom

Should I implement the get_all function in Headers (headers.rs) with the following specification?

Return all values of the `Set-Cookie` header in the `Headers` object with
Returns them as a Result<Vec<String>> type.
Also return an error if the name is not `Set-Cookie`.

nakamura-shuta avatar Jun 18 '24 12:06 nakamura-shuta