From mboxrd@z Thu Jan 1 00:00:00 1970 Delivered-To: chneukirchen@gmail.com Received: by 10.227.175.12 with SMTP id v12csp78122wbz; Mon, 22 Apr 2013 18:48:25 -0700 (PDT) Return-Path: Received-SPF: pass (google.com: domain of rack-devel+bncBCY5V57U5EPBBZ6Q26FQKGQEF5WER3Q@googlegroups.com designates 10.49.103.135 as permitted sender) client-ip=10.49.103.135 Authentication-Results: mr.google.com; spf=pass (google.com: domain of rack-devel+bncBCY5V57U5EPBBZ6Q26FQKGQEF5WER3Q@googlegroups.com designates 10.49.103.135 as permitted sender) smtp.mail=rack-devel+bncBCY5V57U5EPBBZ6Q26FQKGQEF5WER3Q@googlegroups.com; dkim=pass header.i=@googlegroups.com X-Received: from mr.google.com ([10.49.103.135]) by 10.49.103.135 with SMTP id fw7mr10786916qeb.38.1366681705329 (num_hops = 1); Mon, 22 Apr 2013 18:48:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20120806; h=x-received:x-beenthere:x-received:received-spf:mime-version:subject :from:in-reply-to:date:message-id:references:to:x-mailer :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; bh=2PkWZ2LcYM3bIQ6I5asX4H6KsKK5byqy3t55yMKEI34=; b=XpuHumI0RSMaza6PU9WcZc7YgOLBVGssZ+hYAGOu9px14KtTANsNkc8GBDiIfehVro 9Wakd/H/4EpqS2Kqq0jFL1pjQI0tQQyJi+myocWnzBhx05vw09LPhffLsbLRgrdu5Im4 nZmisUAboB7gXdyuAREcQJc+wugNr2YGRy21TZHCZpWjMSh/ZQ9TPUU992a0wjGzvrbF MBMf2AeGZPyjn4IfCKwVm1RX+bdIy89cY9ihHNawXP9OG/2vH/UM2OF8t64hRjQzSKUQ QgcrUsecUUQv7436XyeVPs50LS7VqrloYwmSEKgmVSS9sMpNWO6qe1LJ0mAVCIXq6sQ1 006Q== X-Received: by 10.49.103.135 with SMTP id fw7mr2603138qeb.38.1366681704894; Mon, 22 Apr 2013 18:48:24 -0700 (PDT) X-BeenThere: rack-devel@googlegroups.com Received: by 10.49.50.104 with SMTP id b8ls94084qeo.82.gmail; Mon, 22 Apr 2013 18:48:23 -0700 (PDT) X-Received: by 10.236.37.36 with SMTP id x24mr14857046yha.35.1366681703649; Mon, 22 Apr 2013 18:48:23 -0700 (PDT) Received: from titanium.spork.in (titanium.spork.in. [67.207.128.196]) by gmr-mx.google.com with ESMTP id g7si4935707yhf.0.2013.04.22.18.48.23; Mon, 22 Apr 2013 18:48:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of g@spork.in designates 67.207.128.196 as permitted sender) client-ip=67.207.128.196; Received: from [172.20.10.8] (52.71.224.49.dyn.cust.vf.net.nz [49.224.71.52]) (Authenticated sender: tim@spork.in) by titanium.spork.in (Postfix) with ESMTPSA id 721DDB02E3 for ; Mon, 22 Apr 2013 18:48:22 -0700 (PDT) Mime-Version: 1.0 (Mac OS X Mail 6.3 \(1503\)) Subject: Re: [RFC/PATCH] lint: additional response checking/skipping for hijack From: Tim Carey-Smith In-Reply-To: Date: Tue, 23 Apr 2013 13:48:19 +1200 Message-Id: References: <20130123002048.GA362@dcvr.yhbt.net> To: rack-devel@googlegroups.com X-Mailer: Apple Mail (2.1503) X-Original-Sender: g@spork.in X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: best guess record for domain of g@spork.in designates 67.207.128.196 as permitted sender) smtp.mail=g@spork.in 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=ISO-8859-1 The referenced hijack.ru app returns the IO object instead of returning [200, {}, []]. https://github.com/raggi/thin/blob/e04855459cb42fd98a0a483075f8337cafe6d949/example/hijack.ru#L15 Thanks, Tim On Apr 23, 2013, at 1:37 PM, James Tucker wrote: > The examples do work this way. > > What are you referring to? > > > On Sun, Apr 21, 2013 at 8:41 AM, Tim Carey-Smith wrote: > >> Could you update the examples on the original issue to behave in this way? >> This is a point of confusion, I think. >> >> Perhaps this could be added to the SPEC as well? >> >> On Jan 29, 2013, at 11:01 AM, James Tucker wrote: >> >>> I'd generally recommend that the hijacking app return valid stub data, >>> something like: [200, {}, []]. >>> >>> >>> On 22 January 2013 16:20, Eric Wong wrote: >>> >>>> Not a serious patch for now, at least not all of it. >>>> I suspect middlewares will break badly if the body.each/body.close >>>> checks are enforced. >>>> >>>> --- >>>> lib/rack/lint.rb | 17 +++++++++++++++++ >>>> 1 file changed, 17 insertions(+) >>>> >>>> diff --git a/lib/rack/lint.rb b/lib/rack/lint.rb >>>> index 1bc2127..f895772 100644 >>>> --- a/lib/rack/lint.rb >>>> +++ b/lib/rack/lint.rb >>>> @@ -9,6 +9,7 @@ class Lint >>>> def initialize(app) >>>> @app = app >>>> @content_length = nil >>>> + @response_hijacked = false >>>> end >>>> >>>> # :stopdoc: >>>> @@ -47,6 +48,15 @@ def _call(env) >>>> >>>> ## and returns an Array of exactly three values: >>>> status, headers, @body = @app.call(env) >>>> + >>>> + # hijacked requests may not give a valid response, do not check >> them >>>> + if env.include?("rack.hijack_io") >>>> + # request hijacking implies response hijacking, this will >> ensure >>>> + # the response body raises if body.each or body.close gets >> called >>>> + @response_hijacked = true >>>> + return [ status, headers, self ] >>>> + end >>>> + >>>> ## The *status*, >>>> check_status status >>>> ## the *headers*, >>>> @@ -530,6 +540,7 @@ def check_hijack_response(headers, env) >>>> headers['rack.hijack'] = proc do |io| >>>> original_hijack.call HijackWrapper.new(io) >>>> end >>>> + @response_hijacked = true >>>> else >>>> ## >>>> ## The special response header rack.hijack must only be >>>> set >>>> @@ -636,6 +647,9 @@ def verify_content_length(bytes) >>>> >>>> ## === The Body >>>> def each >>>> + assert("server is not attempting to iterate hijacked response >>>> body") { >>>> + @response_hijacked == false >>>> + } >>>> @closed = false >>>> bytes = 0 >>>> >>>> @@ -683,6 +697,9 @@ def each >>>> end >>>> >>>> def close >>>> + assert("server is not attempting to close hijacked response") { >>>> + @response_hijacked == false >>>> + } >>>> @closed = true >>>> @body.close if @body.respond_to?(:close) >>>> end >>>> -- >>>> Eric Wong >>>> >>> >>> -- >>> >>> --- >>> You received this message because you are subscribed to the Google >> Groups "Rack Development" group. >>> To unsubscribe from this group, send email to >> rack-devel+unsubscribe@googlegroups.com. >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >>> >> >> -- >> >> --- >> You received this message because you are subscribed to the Google Groups >> "Rack Development" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to rack-devel+unsubscribe@googlegroups.com. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > > -- > > --- > You received this message because you are subscribed to the Google Groups "Rack Development" group. > To unsubscribe from this group and stop receiving emails from it, send an email to rack-devel+unsubscribe@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > > -- --- You received this message because you are subscribed to the Google Groups "Rack Development" group. To unsubscribe from this group and stop receiving emails from it, send an email to rack-devel+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.