unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
From: Eric Wong <normalperson@yhbt.net>
To: unicorn list <mongrel-unicorn@rubyforge.org>
Subject: Re: problem setting multiple cookies
Date: Mon, 20 Jun 2011 17:46:07 -0700	[thread overview]
Message-ID: <20110621004607.GA29647@dcvr.yhbt.net> (raw)
In-Reply-To: <BANLkTi=EzX=qiv=V_ZXVrWY3PETjVBbFYw@mail.gmail.com>

Jason Su <jason@lookbook.nu> wrote:
> Hey Eric,
> 
> I'm using Rails 2.3.8, and Rack 1.1.2

Please don't top post, if you're just replying to the message in general
I'd rather you not quote at all.

> I'm setting cookies like this:
> 
> cookies[:user_id] = { :domain => ".#{domain}", :value => "#{user.id}",
> :expires => 10.years.from_now }

> How can I get the response to show up correctly, with individual
> Set-Cookie lines for each?

I wonder if it's a bug in older versions of Rails or Rack, there was
some confusion back in the day about how to handle multiple values
for a single header...

Can you try loading the following middleware in your app?

If it doesn't work, uncomment the 'p' statement and show us what data
structure is used for your headers.

---------------------- join_cookie.rb ---------------------------------
# Totally untested:
# usage (in config.ru):
#   use JoinCookie
#   run YourApp.new
class JoinCookie < Struct.new(:app)
  def call(env)
    status, headers, body = app.call(env)

    ## uncomment and show me the output of the next line if this doesn't work
    # p headers

    headers = Rack::Utils::HeaderHash.new(headers)
    case set_cookie = headers["Set-Cookie"]
    when Array
      headers["Set-Cookie"] = set_cookie.join("\n")
    end

    [ status, headers, body ]
  end
end
-----------------------------------------------------------------

-- 
Eric Wong
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying


  reply	other threads:[~2011-06-21  1:09 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-20 23:40 problem setting multiple cookies Jason Su
2011-06-21  0:06 ` Eric Wong
2011-06-21  0:25   ` Jason Su
2011-06-21  0:46     ` Eric Wong [this message]
2011-06-21  1:34       ` Jason Su
2011-06-21  1:35         ` Jason Su
2011-06-21  2:15         ` Eric Wong
2011-06-21  2:48           ` Jason Su
2011-06-21  3:15             ` Eric Wong
2011-06-21  3:38               ` Jason Su
2011-06-21 18:29                 ` Eric Wong
2011-06-22  1:01                   ` Jason Su
2011-06-22  1:59                     ` Eric Wong
2011-06-22  4:18                       ` Jason Su
2011-06-22  4:20                         ` Jason Su
2011-06-22  6:02                         ` Eric Wong
2011-06-22 12:51                           ` Jason Su

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=20110621004607.GA29647@dcvr.yhbt.net \
    --to=normalperson@yhbt.net \
    --cc=mongrel-unicorn@rubyforge.org \
    /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).