From mboxrd@z Thu Jan 1 00:00:00 1970 Delivered-To: chneukirchen@gmail.com Received: by 10.49.85.105 with SMTP id g9csp258368qez; Tue, 22 Jan 2013 03:37:52 -0800 (PST) Return-Path: Received-SPF: pass (google.com: domain of rack-devel+bncBDKJRJVBSMLBBDXU7GDQKGQENTPU7PQ@googlegroups.com designates 10.50.217.201 as permitted sender) client-ip=10.50.217.201 Authentication-Results: mr.google.com; spf=pass (google.com: domain of rack-devel+bncBDKJRJVBSMLBBDXU7GDQKGQENTPU7PQ@googlegroups.com designates 10.50.217.201 as permitted sender) smtp.mail=rack-devel+bncBDKJRJVBSMLBBDXU7GDQKGQENTPU7PQ@googlegroups.com; dkim=pass header.i=@googlegroups.com X-Received: from mr.google.com ([10.50.217.201]) by 10.50.217.201 with SMTP id pa9mr13493156igc.17.1358854671834 (num_hops = 1); Tue, 22 Jan 2013 03:37:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20120806; h=x-received:x-beenthere:x-received:x-received:received-spf:date:from :to:subject:message-id:mime-version:user-agent:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:x-google-group-id:list-post:list-help:list-archive:sender :list-subscribe:list-unsubscribe:content-type:content-disposition; bh=I6isOrZ7ekLJeKjX4PT2lap8fj1gtfE8gkPExVvzXUQ=; b=H9C++d9khCUCiS9njWD4rRU9GstbjIp1cw71Kpu72UxE8OqlGnNPi2eSvmyKcj5vg+ rPMvo/LuJ8L3ji7cO8o7W7GaZvKCo3KoiETm6kFVJdMth7n4BcrMqgFezNl6aJ0oGVUa xYQItw5CjGD4Ktlj0etu3ysv5Cc12JfW0U/T5ayy9RK5AFoAdp4aRCHcDcnDE+ycDWZF +pyqdSNC9+PvrCS2m2JgJ60Nzhr+yB4uLPQo3INTLthqnDYhxj6OcPjtcHu9OAcgFhFo hKvuMzB7UDQ7X3ODvD0SgpYvkoA1FlWAj4pfyVq1iO73tutmhMBkpGmg0jgbP7zRRcB7 WRPg== X-Received: by 10.50.217.201 with SMTP id pa9mr3766262igc.17.1358854671404; Tue, 22 Jan 2013 03:37:51 -0800 (PST) X-BeenThere: rack-devel@googlegroups.com Received: by 10.50.15.168 with SMTP id y8ls3062498igc.5.canary; Tue, 22 Jan 2013 03:37:50 -0800 (PST) X-Received: by 10.66.89.74 with SMTP id bm10mr2288810pab.19.1358854670102; Tue, 22 Jan 2013 03:37:50 -0800 (PST) X-Received: by 10.66.89.74 with SMTP id bm10mr2288809pab.19.1358854670091; Tue, 22 Jan 2013 03:37:50 -0800 (PST) Received: from dcvr.yhbt.net (dcvr.yhbt.net. [64.71.152.64]) by gmr-mx.google.com with ESMTP id uz6si3072586pbc.0.2013.01.22.03.37.49; Tue, 22 Jan 2013 03:37:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of normalperson@yhbt.net designates 64.71.152.64 as permitted sender) client-ip=64.71.152.64; Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 3EA5B1F408; Tue, 22 Jan 2013 11:37:49 +0000 (UTC) Date: Tue, 22 Jan 2013 11:37:49 +0000 From: Eric Wong To: rack-devel@googlegroups.com Subject: [PATCH] lint: avoid TypeError on non-Hash-like response headers Message-ID: <20130122113749.GA31589@dcvr.yhbt.net> MIME-Version: 1.0 User-Agent: Mutt/1.5.21 (2010-09-15) X-Original-Sender: normalperson@yhbt.net X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: best guess record for domain of normalperson@yhbt.net designates 64.71.152.64 as permitted sender) smtp.mail=normalperson@yhbt.net Reply-To: rack-devel@googlegroups.com Precedence: list Mailing-list: list rack-devel@googlegroups.com; contact rack-devel+owners@googlegroups.com List-ID: X-Google-Group-Id: 486215384060 List-Post: , List-Help: , List-Archive: Sender: rack-devel@googlegroups.com List-Subscribe: , List-Unsubscribe: , Content-Type: text/plain; charset=us-ascii Content-Disposition: inline According to SPEC (and check_headers), Response headers need only respond to #each. Thus, check_hijack_response should rely on Rack::Utils::HeaderHash if it wishes to access the headers in a hash-like fashion. --- The following changes since commit 0cba6a4d5aeb1ac8768b6ca36320731487fb596b: Update gemspec version, Rack 1.5.0 (2013-01-21 23:36:04 -0800) are available in the git repository at: git://bogomips.org/rack lint-headerhash for you to fetch changes up to b20b0023d6f4676a6f0645a522656b384446562a: lint: avoid TypeError on non-Hash-like response headers (2013-01-22 11:36:04 +0000) ---------------------------------------------------------------- Eric Wong (1): lint: avoid TypeError on non-Hash-like response headers lib/rack/lint.rb | 5 +++++ test/spec_lint.rb | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/lib/rack/lint.rb b/lib/rack/lint.rb index 338f7f0..1bc2127 100644 --- a/lib/rack/lint.rb +++ b/lib/rack/lint.rb @@ -500,6 +500,11 @@ def check_hijack(env) ## It is also possible to hijack a response after the status and headers ## have been sent. def check_hijack_response(headers, env) + + # this check uses headers like a hash, but the spec only requires + # headers respond to #each + headers = Rack::Utils::HeaderHash.new(headers) + ## In order to do this, an application may set the special header ## rack.hijack to an object that responds to call ## accepting an argument that conforms to the rack.hijack_io diff --git a/test/spec_lint.rb b/test/spec_lint.rb index f824113..fb60b7e 100644 --- a/test/spec_lint.rb +++ b/test/spec_lint.rb @@ -231,6 +231,13 @@ def result.name [200, {"Foo-Bar" => "one\ntwo\nthree", "Content-Length" => "0", "Content-Type" => "text/plain" }, []] }).call(env({})) }.should.not.raise(Rack::Lint::LintError) + + # non-Hash header responses should be allowed + lambda { + Rack::Lint.new(lambda { |env| + [200, [%w(Content-Type text/plain), %w(Content-Length 0)], []] + }).call(env({})) + }.should.not.raise(TypeError) end should "notice content-type errors" do -- Eric Wong