From mboxrd@z Thu Jan 1 00:00:00 1970 Delivered-To: chneukirchen@gmail.com Received: by 10.103.134.12 with SMTP id l12cs239172mun; Wed, 7 Oct 2009 01:35:14 -0700 (PDT) Received-SPF: pass (google.com: domain of grbounce-ceibQwUAAAB4YPBqaDIjI2bFOCxyyh3G=chneukirchen=gmail.com@googlegroups.com designates 10.142.4.4 as permitted sender) client-ip=10.142.4.4; Authentication-Results: mr.google.com; spf=pass (google.com: domain of grbounce-ceibQwUAAAB4YPBqaDIjI2bFOCxyyh3G=chneukirchen=gmail.com@googlegroups.com designates 10.142.4.4 as permitted sender) smtp.mail=grbounce-ceibQwUAAAB4YPBqaDIjI2bFOCxyyh3G=chneukirchen=gmail.com@googlegroups.com; dkim=pass header.i=grbounce-ceibQwUAAAB4YPBqaDIjI2bFOCxyyh3G=chneukirchen=gmail.com@googlegroups.com Received: from mr.google.com ([10.142.4.4]) by 10.142.4.4 with SMTP id 4mr1964266wfd.15.1254904512603 (num_hops = 1); Wed, 07 Oct 2009 01:35:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=domainkey-signature:received:received:x-sender:x-apparently-to :received:received:received:received-spf:received:date:from:to :subject:message-id:mime-version:content-type:content-disposition :user-agent:reply-to:sender:precedence:x-google-loop:mailing-list :list-id:list-post:list-help:list-unsubscribe:x-beenthere-env :x-beenthere; bh=Y4+xTNrR5NvCSuHpLndq54sO2zM40+YgiTlQOg5Zty0=; b=16iOJRG/V86Hsv4HmeMd/BPAEkD0OBa25Ha2hZXWZWrV5sPm9DaakKlyAqbfc0NBPk M199uXh1K2S88PaiPXgJAqHZkfbJNMqtQkiX+GRKzMkJx+96a8rbldHjHeoRfieY7j1C EG6WwiVCrcMGnD72dAObk9uaI1Zk+vQZw3pk4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlegroups.com; s=beta; h=x-sender:x-apparently-to:received-spf:authentication-results:date :from:to:subject:message-id:mime-version:content-type :content-disposition:user-agent:reply-to:sender:precedence :x-google-loop:mailing-list:list-id:list-post:list-help :list-unsubscribe:x-beenthere-env:x-beenthere; b=bPEMb0YvjM0HFivLItCh2ma8drQDM85MTMJxvDujAMXXOAFwgZu1lj4xmheGEwpHln LNeKqXqCqpVFclQfTaWV5/HdGEhWIWqvdEHeb5SdkyrnLxfZj9Cr43UFamL70rxNcOs9 uJUkVJrlDnnUSbTx0O8JSXeyspIjlEdZGJHlA= Received: by 10.142.4.4 with SMTP id 4mr181344wfd.15.1254904512551; Wed, 07 Oct 2009 01:35:12 -0700 (PDT) Received: by 10.107.137.4 with SMTP id p4gr1688prn.0; Wed, 07 Oct 2009 01:35:01 -0700 (PDT) X-Sender: normalperson@yhbt.net X-Apparently-To: rack-devel@googlegroups.com Received: by 10.142.196.1 with SMTP id t1mr1250564wff.2.1254904499648; Wed, 07 Oct 2009 01:34:59 -0700 (PDT) Received: by 10.142.196.1 with SMTP id t1mr1250563wff.2.1254904499630; Wed, 07 Oct 2009 01:34:59 -0700 (PDT) Return-Path: Received: from dcvr.yhbt.net (dcvr.yhbt.net [64.71.152.64]) by gmr-mx.google.com with ESMTP id 3si142871pxi.5.2009.10.07.01.34.59; Wed, 07 Oct 2009 01:34:59 -0700 (PDT) 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; 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 Received: from localhost (user-118bg0q.cable.mindspring.com [66.133.192.26]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPSA id C796A1F793; Wed, 7 Oct 2009 08:34:58 +0000 (UTC) Date: Wed, 7 Oct 2009 01:34:58 -0700 From: Eric Wong To: rack-devel@googlegroups.com Subject: Add readpartial to rack.input spec? Message-ID: <20091007083458.GB20541@dcvr.yhbt.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) Reply-To: rack-devel@googlegroups.com Sender: rack-devel@googlegroups.com Precedence: bulk X-Google-Loop: groups Mailing-List: list rack-devel@googlegroups.com; contact rack-devel+owner@googlegroups.com List-Id: List-Post: List-Help: List-Unsubscribe: , X-BeenThere-Env: rack-devel@googlegroups.com X-BeenThere: rack-devel@googlegroups.com Hi all, I just had to modify[1] the default TeeInput semantics of Unicorn to work around (what I consider) a bug[2] in Rails request handling for urlencoded forms. And I'm willing to bet Rails isn't the only thing that doesn't check the size of the return value for body.read(length) as Ruby's IO currently always /seems/ to return the specified amount (except for the last block before EOF). So I guess that's why Ruby has IO#readpartial implemented... So now for the majority of requests with a specified Content-Length, TeeInput#read(length) will return length bytes. But for those rare chunked bodies, TeeInput#read(length) will continue to behave like IO#readpartial. This may confuse some folks, but chunked request bodies are still rare, maybe adding readpartial will be less confusing as chunked request bodies become more common (I know some mobile devices send them, especially for voice/video data). In Unicorn, I kept the readpartial behavior for the chunked case because some applications rely on bidirectional chunking. Both the client and server can simultaneously send chunks back-and-forth and either side may depend on the other before outputting more. With client support, this allows any connection-based protocol to be tunneled through HTTP chunked request/response bodies. Of course Unicorn (and by extension, Rainbows![3]) are the only servers I know with this bidirectional chunk streaming capability... [1] http://git.bogomips.org/cgit/unicorn.git/commit/?id=438c99aec2d74489fa89b3a6c60d1fb41bb2f7e6 [2] https://rails.lighthouseapp.com/projects/8994/tickets/3343-ensure-raw_post-reads-all-of-the-specified-length#ticket-3343-1 [3] I expect to see this used from Rainbows! more since it can do slow clients -- Eric Wong