From mboxrd@z Thu Jan 1 00:00:00 1970 Delivered-To: chneukirchen@gmail.com Received: by 10.239.138.72 with SMTP id o8cs113093hbo; Thu, 20 May 2010 10:36:59 -0700 (PDT) Received-SPF: pass (google.com: domain of rack-devel+bncCOyNj53IGxC45tXfBBoEnR7qxQ@googlegroups.com designates 10.101.152.38 as permitted sender) client-ip=10.101.152.38; Authentication-Results: mr.google.com; spf=pass (google.com: domain of rack-devel+bncCOyNj53IGxC45tXfBBoEnR7qxQ@googlegroups.com designates 10.101.152.38 as permitted sender) smtp.mail=rack-devel+bncCOyNj53IGxC45tXfBBoEnR7qxQ@googlegroups.com; dkim=pass header.i=rack-devel+bncCOyNj53IGxC45tXfBBoEnR7qxQ@googlegroups.com Received: from mr.google.com ([10.101.152.38]) by 10.101.152.38 with SMTP id e38mr130977ano.26.1274377017710 (num_hops = 1); Thu, 20 May 2010 10:36:57 -0700 (PDT) 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:received:received:date :in-reply-to:x-ip:references:user-agent:x-http-useragent: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:sender:list-subscribe:list-unsubscribe:content-type :content-transfer-encoding; bh=9F+OVY4Yt+2yN89hYkftRoClwIAVX6K3GFaeyZgqjaA=; b=PsuNQPeT9PNoStk2yizaxl6KwXE0Uy1+rbSccyyqVg4/+9BuFENxOIs7IeI0zpxuNU T2BOD5ovdksmoNKtJhqWFf/xgTWy2LaYAl+mfUvUOecybSJaWJ+mdDhr4Olydt4UALiA CFb387WbHs19rx7/UYhnQziO/xCeXo2veNWNw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlegroups.com; s=beta; h=x-beenthere:received-spf:mime-version:date:in-reply-to:x-ip :references:user-agent:x-http-useragent: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 :sender:list-subscribe:list-unsubscribe:content-type :content-transfer-encoding; b=PNIvVtk6JtXe8+zLxu0WUpeyuLZVuNwX5n+Ikm3JQZd0ld+RNhmxpHXzbiWPtsAlvQ 2xFt6MgZI9tDxk7j8xGTIQYGoJKD6utNzP2qkdfjOyn+aoQaRBWZMhCIS5YyHI5xSHK1 GFhrYqIFL692BLy7da7VH50hdvdzxW4rkLmEs= Received: by 10.101.152.38 with SMTP id e38mr28739ano.26.1274377016305; Thu, 20 May 2010 10:36:56 -0700 (PDT) X-BeenThere: rack-devel@googlegroups.com Received: by 10.91.91.6 with SMTP id t6ls108808agl.0.p; Thu, 20 May 2010 10:36:55 -0700 (PDT) Received: by 10.150.48.22 with SMTP id v22mr613369ybv.10.1274377014972; Thu, 20 May 2010 10:36:54 -0700 (PDT) Received: by 10.150.48.22 with SMTP id v22mr613364ybv.10.1274377014455; Thu, 20 May 2010 10:36:54 -0700 (PDT) Return-Path: Received: from mail-gw0-f61.google.com (mail-gw0-f61.google.com [74.125.83.61]) by gmr-mx.google.com with ESMTP id z7si1767634ybc.6.2010.05.20.10.36.54; Thu, 20 May 2010 10:36:54 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.83.61 is neither permitted nor denied by best guess record for domain of max@maxcantor.net) client-ip=74.125.83.61; Received: by mail-gw0-f61.google.com with SMTP id 18so71795gwj.16 for ; Thu, 20 May 2010 10:36:54 -0700 (PDT) MIME-Version: 1.0 Received: by 10.101.179.38 with SMTP id g38mr32466anp.54.1274377014080; Thu, 20 May 2010 10:36:54 -0700 (PDT) Received: by o39g2000vbd.googlegroups.com with HTTP; Thu, 20 May 2010 10:36:54 -0700 (PDT) Date: Thu, 20 May 2010 10:36:54 -0700 (PDT) In-Reply-To: X-IP: 207.58.192.150 References: User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Chrome/4.0.249.89 Safari/532.5,gzip(gfe) Message-ID: <42cbee50-0818-4c65-a5f5-252f0b18f885@o39g2000vbd.googlegroups.com> Subject: Re: Patch: Make CGI handler obey rack spec for the greater good From: Max Cantor To: Rack Development X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 74.125.83.61 is neither permitted nor denied by best guess record for domain of max@maxcantor.net) smtp.mail=max@maxcantor.net X-Original-Sender: max@maxcantor.net 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: Sender: rack-devel@googlegroups.com List-Subscribe: , List-Unsubscribe: , Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On May 20, 10:09=A0am, James Tucker wrote: > On 12 May 2010, at 10:24, Max Cantor wrote: > > > The default CGI handler included in rack doesn't obey the rack spec; > > its input stream is not rewindable, and thus generates Errno::ESPIPE > > illegal seek errors. =A0You can see the Sinatra guys needed a workaroun= d > > for it here:https://sinatra.lighthouseapp.com/projects/9779/tickets/227= -errnoespi... > > > This patch wraps the CGI handler's input stream in a rewindable input > > object, which makes the handler adhere to the rack spec. > > Didn't we say this was optional in the spec? > > This could be a middleware, as has been discussed elsewhere on this ML in= the last 6 months. >From the spec at http://rack.rubyforge.org/doc/SPEC.html: > The input stream is an IO-like object which contains the raw HTTP POST da= ta. When applicable, its external encoding must be =93ASCII-8BIT=94 and it = must be opened in binary mode, for Ruby 1.9 compatibility. The input stream= must respond to gets, each, read and rewind. > rewind must be called without arguments. It rewinds the input stream back= to the beginning. It must not raise Errno::ESPIPE: that is, it may not be = a pipe or a socket. Therefore, handler developers must buffer the input dat= a into some rewindable object if the underlying input stream is not rewinda= ble. Perhaps it is out of date or I am interpreting it incorrectly, but I took the "must" in those paragraphs to heart--my mistake if I'm reading the wrong part of the spec or something. Do you feel like there's a good reason to not make the CGI handler's input stream rewindable? Every time I update rack, I have to re-patch it myself, because it never works. It seems pretty unintuitive to require adding middleware just to make the CGI handler work at all. - Max