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

Hey Eric,

I'm using Rails 2.3.8, and Rack 1.1.2

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?

Thanks again,

Jason



On Mon, Jun 20, 2011 at 5:06 PM, Eric Wong <normalperson@yhbt.net> wrote:
> Jason Su <jason@lookbook.nu> wrote:
>> Hey guys,
>>
>> When I try to set multiple cookies in one request, the 'Set-Cookies'
>> header in the http response doesn't look right -- all the cookies are
>> set without any line breaks.
>>
>> Looks like this:
>>
>> Set-Cookie:first=; domain=.domain.com; path=/; expires=Thu,
>> 01-Jan-1970 00:00:00 GMTsecond=1; domain=.domain.com; path=/;
>> expires=Sun, 20-Jun-2021 23:34:30 GMT
>
> Which versions of Rails and Rack are you using?  How is your app
> setting cookies?
>
> Older versions of Rack may have specified a different delimiter (or an
> Array).  Current versions only use "\n" inside a string, so it should be
> something like:
>
>  headers["Set-Cookie"] = "first=33; path=/\n" \
>                          "second=; path=/\n" \
>                          "third=; path=/"
>
> Using Rack::Utils.set_cookie_header! (or a Rails-level wrapper) is
> recommended, though.
>
>> Should look more like this, which is what I got from a fresh Rails project test:
>>
>> Set-Cookie:first=33; path=/
>> second=; path=/; expires=Thu, 01-Jan-1970 00:00:00 GMT
>> third=69; path=/
>
> The response should have 3 individual Set-Cookie lines:
>
>  Set-Cookie: first=33; path=/
>  Set-Cookie: second=; path=/; expires=Thu, 01-Jan-1970 00:00:00 GMT
>  Set-Cookie: third=69; path=/
>
>> In the first example, neither cookies (first/second) are set. The
>> second example, all 3 cookies are set.
>>
>> I think it's happening somewhere here, but I can't figure out what's
>> going on... http://bogomips.org/unicorn.git/tree/lib/unicorn/cgi_wrapper.rb
>
> The code that does this transformation of the Rack header to the
> client socket is here:
>
> http://bogomips.org/unicorn.git/tree/lib/unicorn/http_response.rb
>
> cgi_wrapper.rb is only for Rails <= 2.2, where it is called before
> http_response.rb
>
> --
> 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
>
_______________________________________________
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  0:25 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 [this message]
2011-06-21  0:46     ` Eric Wong
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='BANLkTi=EzX=qiv=V_ZXVrWY3PETjVBbFYw@mail.gmail.com' \
    --to=jason@lookbook.nu \
    --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).