From mboxrd@z Thu Jan 1 00:00:00 1970 Delivered-To: chneukirchen@gmail.com Received: by 10.140.140.3 with SMTP id n3cs204617rvd; Thu, 4 Mar 2010 07:48:23 -0800 (PST) Received-SPF: pass (google.com: domain of 3RNaPSwgJCvUoqljXvhldjXfi.ZljoXZh-absbidlldibdolrmp.Zlj@groups.bounces.google.com designates 10.229.2.31 as permitted sender) client-ip=10.229.2.31; Authentication-Results: mr.google.com; spf=pass (google.com: domain of 3RNaPSwgJCvUoqljXvhldjXfi.ZljoXZh-absbidlldibdolrmp.Zlj@groups.bounces.google.com designates 10.229.2.31 as permitted sender) smtp.mail=3RNaPSwgJCvUoqljXvhldjXfi.ZljoXZh-absbidlldibdolrmp.Zlj@groups.bounces.google.com; dkim=pass header.i=3RNaPSwgJCvUoqljXvhldjXfi.ZljoXZh-absbidlldibdolrmp.Zlj@groups.bounces.google.com Received: from mr.google.com ([10.229.2.31]) by 10.229.2.31 with SMTP id 31mr1738012qch.3.1267717702412 (num_hops = 1); Thu, 04 Mar 2010 07:48:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=domainkey-signature:received:x-beenthere:received:received:received :received:received-spf:received:mime-version:sender:received :in-reply-to:references:date:message-id:subject:from:to :x-original-authentication-results:x-original-sender:reply-to :precedence:mailing-list:list-id:list-post:list-help:list-archive :x-thread-url:x-message-url:list-subscribe:list-unsubscribe :content-type; bh=VAU/xLuREvscFffOu0FXgo7ttv0DXstCzUgwKQWWOvA=; b=dCrgw9L6cKvMZeiNW3s6DbZhrSqNIbiMUBGmiCJ+Ssfmi4SJjvYWFedGCS0H92LJIB q5jXbhQUAiwBi2nrrUWiOBuVjeJt3IFd/zFiedjRUzTsIjXh23j76Zxe2979J4qqDzAN VcD0kZRgnoHU0pFsbsA8FcYZpUUWftKLsOqnE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlegroups.com; s=beta; h=x-beenthere:received-spf:mime-version:sender:in-reply-to:references :date:message-id:subject:from:to:x-original-authentication-results :x-original-sender:reply-to:precedence:mailing-list:list-id :list-post:list-help:list-archive:x-thread-url:x-message-url :list-subscribe:list-unsubscribe:content-type; b=1b7nVh9eyHTwZz70sbc2xzqvxG+i/4F+Z8YNniVwrZdKTjvq/zZNGDpd+XQBl4Ye7x KUCN8LYTMVDEKi35md1cfPzXOVrPn/AZhnrMCA/SkD7N5NgWk8No73Xu8yzhaCff0ayq o3H9HZgnFtZ846qLmGYDqKxnDUZZtva4iLWd0= Received: by 10.229.2.31 with SMTP id 31mr189759qch.3.1267717700752; Thu, 04 Mar 2010 07:48:20 -0800 (PST) X-BeenThere: rack-devel@googlegroups.com Received: by 10.229.34.9 with SMTP id j9ls648565qcd.3.p; Thu, 04 Mar 2010 07:48:18 -0800 (PST) Received: by 10.229.225.77 with SMTP id ir13mr726208qcb.10.1267717698695; Thu, 04 Mar 2010 07:48:18 -0800 (PST) Received: by 10.229.225.77 with SMTP id ir13mr726207qcb.10.1267717698664; Thu, 04 Mar 2010 07:48:18 -0800 (PST) Return-Path: Received: from qw-out-1920.google.com (qw-out-1920.google.com [74.125.92.150]) by gmr-mx.google.com with ESMTP id 25si43531qyk.15.2010.03.04.07.48.17; Thu, 04 Mar 2010 07:48:17 -0800 (PST) Received-SPF: pass (google.com: domain of rtomayko@gmail.com designates 74.125.92.150 as permitted sender) client-ip=74.125.92.150; Received: by qw-out-1920.google.com with SMTP id 5so537508qwf.46 for ; Thu, 04 Mar 2010 07:48:17 -0800 (PST) MIME-Version: 1.0 Sender: rack-devel@googlegroups.com Received: by 10.224.114.9 with SMTP id c9mr2176105qaq.148.1267717681340; Thu, 04 Mar 2010 07:48:01 -0800 (PST) In-Reply-To: References: Date: Thu, 4 Mar 2010 07:48:01 -0800 Message-ID: Subject: Re: Rack::ETag does not set headers for Array type response bodies From: Ryan Tomayko To: rack-devel@googlegroups.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of rtomayko@gmail.com designates 74.125.92.150 as permitted sender) smtp.mail=rtomayko@gmail.com; dkim=pass (test mode) header.i=@gmail.com X-Original-Sender: r@tomayko.com Reply-To: rack-devel@googlegroups.com Precedence: list Mailing-list: list rack-devel@googlegroups.com; contact rack-devel+owners@googlegroups.com List-ID: List-Post: , List-Help: , List-Archive: X-Thread-Url: http://groups.google.com/group/rack-devel/t/b004673ecda03f80 X-Message-Url: http://groups.google.com/group/rack-devel/msg/c62ffdae12fde520 List-Subscribe: , List-Unsubscribe: , Content-Type: text/plain; charset=UTF-8 On Thu, Mar 4, 2010 at 5:17 AM, Karel Minarik 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