rack-devel archive mirror (unofficial) https://groups.google.com/group/rack-devel
 help / color / mirror / Atom feed
From: Eric Wong <normalperson@yhbt.net>
To: rack-devel@googlegroups.com
Subject: Re: Rack::Lint and Set-Cookie
Date: Sun, 31 Jan 2010 21:09:09 -0800	[thread overview]
Message-ID: <20100201050909.GA21823@dcvr.yhbt.net> (raw)
In-Reply-To: <36cbf159-4a8e-4109-b315-5b2fc57a820a@f12g2000yqn.googlegroups.com>

agilesoftware <agilesoftware@gmail.com> wrote:
> in Utils.set_cookie_header!(header, key, value)
> 
>   case header["Set-Cookie"]
>       when Array
>         header["Set-Cookie"] << cookie
>       when String
>         header["Set-Cookie"] = [header["Set-Cookie"], cookie]
>       when nil
>         header["Set-Cookie"] = cookie
>       end
> 
> but in Rack::Lint:
> 
>     def check_headers(header)
>       header.each { |key, value|
>          .......
>         assert("a header value must be a String, but the value of " +
>           "'#{key}' is a #{value.class}") { value.kind_of? String }
>         ## consisting of lines (for multiple header values, e.g.
> multiple
>         ## <tt>Set-Cookie</tt> values) seperated by "\n".
>         value.split("\n").each { |item|
>           ## The lines must not contain characters below 037.
>           assert("invalid header value #{key}: #{item.inspect}") {
>             item !~ /[\000-\037]/
>           }
>         }
>       }
>     end
> 
> 
> So if I have any Set-Cookie header set in my Rack application, Lint
> will fail.

Hi,

If your header is a Rack::Utils::HeaderHash object, then header.each
should be yielding strings in Rack 1.1.0:

------------- rack-1.1.0/lib/rack/utils.rb -------------------
    class HeaderHash < Hash
      # snipped
      def each
        super do |k, v|
          yield(k, v.respond_to?(:to_ary) ? v.to_ary.join("\n") : v)
        end
      end
--------------------------------------------------------------

On the other hand, another user reported something similar on the
Unicorn mailing list, too (still unresolved):

  http://mid.gmane.org/AAD43046-6AF4-4685-933D-41F7E1DC0795@meticulo.com

I could not reproduce the issue when I tried...

-- 
Eric Wong

      reply	other threads:[~2010-02-01  5:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-29 12:57 Rack::Lint and Set-Cookie agilesoftware
2010-02-01  5:09 ` Eric Wong [this message]

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-list from there: mbox

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

  List information: https://groups.google.com/group/rack-devel

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

  git send-email \
    --in-reply-to=20100201050909.GA21823@dcvr.yhbt.net \
    --to=rack-devel@googlegroups.com \
    /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.
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).