rack-devel archive mirror (unofficial) https://groups.google.com/group/rack-devel
 help / color / mirror / Atom feed
From: Ryan Tomayko <r@tomayko.com>
To: rack-devel@googlegroups.com
Subject: Re: Rack::ETag does not set headers for Array type response bodies
Date: Thu, 4 Mar 2010 07:48:01 -0800	[thread overview]
Message-ID: <f732822d1003040748p231556c6x85aa6b7a91a06380@mail.gmail.com> (raw)
In-Reply-To: <fa43be89-2d15-4a19-9f88-dbb4df0b3bc4@t23g2000yqt.googlegroups.com>

On Thu, Mar 4, 2010 at 5:17 AM, Karel Minarik <karel.minarik@gmail.com> wrote:
> Hi,
>
> I wanted to `use Rack::ETag` from rack-contrib [1] to automatically
> set ETag headers in a Sinatra application, and discovered that it
> checks whether the response body is a String. Since Rack response
> bodies are _specifically_ required to _not_ be an instance of String
> -- as far as I understand [2] -- and eg. Sinatra serves an Array by
> default [3], this fails.
>
> The solution would be to just call `body.to_s`, as you can see in this
> commit: [4]. I am not sure how it would affect streaming responses,
> but the current implementation of Rack::ETag is more or less useless
> in Sinatra /and possibly elsewhere/.
>
> Karel
>
> [1] http://github.com/rack/rack-contrib/blob/master/lib/rack/contrib/etag.rb
> [2] http://rack.rubyforge.org/doc/files/SPEC.html
> [3] http://github.com/sinatra/sinatra/blob/master/lib/sinatra/base.rb#L57-62
> [4] http://github.com/karmi/rack-contrib/commit/56f02f3e294cece010caed7865581ba63be6f868#diff-0
>

Rack::ETag has been a part of Rack core for a while now:

http://github.com/rack/rack/blob/master/lib/rack/etag.rb

It fixes the issues mentioned. I'll remove the version contrib.

Thanks,
Ryan

  reply	other threads:[~2010-03-04 15:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-04 13:17 Rack::ETag does not set headers for Array type response bodies Karel Minarik
2010-03-04 15:48 ` Ryan Tomayko [this message]
2010-03-04 17:49   ` Karel Minarik

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=f732822d1003040748p231556c6x85aa6b7a91a06380@mail.gmail.com \
    --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).