unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
From: Martin Posthumus <martin.posthumus@gmail.com>
To: unicorn-public@yhbt.net
Subject: Support for Rack 3 headers formatted as arrays
Date: Fri, 9 Dec 2022 16:52:33 -0500	[thread overview]
Message-ID: <f25e283e-95e7-a812-c0fd-c79bc31894de@gmail.com> (raw)

Hello,

As of Rack v3, the internal representation of headers containing 
multiple values appears to have been changed to use an array of strings 
rather than a newline-separated string. Pull request visible here: 
https://github.com/rack/rack/pull/1793

The Rack changelog (https://github.com/rack/rack/blob/main/CHANGELOG.md) 
also includes this entry under 3.0.0:
"Response header values can be an Array to handle multiple values (and 
no longer supports \n encoded headers)."



I'm running into some serialization issues with this sort of header when 
trying to run an application on Unicorn that makes use of multiple 
cookies. The `set-cookie` header is returning what appears to be a 
stringified array:

set-cookie: ["my.cookie=.....; domain=......; path=/", 
"rack.session=......; path=/; httponly"]

Which in turn results in cookies getting registered with names like 
`["rack.session` rather than `rack.session`.


I'm not especially familiar with Unicorn's internals, but poking around 
a little bit, it looks like this might be related to the definition of 
`http_response_write` in lib/unicorn/http_response.rb, where it handles 
newline-separated strings, but not arrays. I can confirm that the 
set-cookie header value appears to be an array in this method, not a string.


At present I'm only seeing this issue when running on a Unicorn server. 
When I swap out something like webrick, it appears the array values are 
handled as expected.


Thank you,

Martin

             reply	other threads:[~2022-12-09 21:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-09 21:52 Martin Posthumus [this message]
2022-12-10  2:42 ` Support for Rack 3 headers formatted as arrays Eric Wong
2022-12-12 15:52   ` Martin Posthumus
2022-12-25 22:56     ` Eric Wong
2022-12-27  8:17       ` Jean Boussier
2023-01-11 11:12       ` Jean Boussier
2023-01-11 11:40         ` Eric Wong
2023-01-11 11:44           ` Jean Boussier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://yhbt.net/unicorn/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f25e283e-95e7-a812-c0fd-c79bc31894de@gmail.com \
    --to=martin.posthumus@gmail.com \
    --cc=unicorn-public@yhbt.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhbt.net/unicorn.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).