From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 808732018F; Wed, 13 Jul 2016 20:24:31 +0000 (UTC) Date: Wed, 13 Jul 2016 20:24:31 +0000 From: Eric Wong To: Kevin Mullican Cc: rainbows-public@bogomips.org Subject: Re: issue between rainbows/unicorn 5.0.0 and rack on ruby >= 1.9.1 Message-ID: <20160713202431.GA10605@dcvr.yhbt.net> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: Kevin Mullican wrote: > Greetings, > > We have run into a problem while trying to use rainbows/unicorn 5.0.0 > on ruby >= 1.9.1. The issue is with rack. As of ruby 1.9.1, String no > longer responds to #each, however it seems that rainbows is still > sending a string body through rack. See: > > rainbows-5.0.0/lib/rainbows/process_client.rb:51: in `write_response` > > which enters rack at: > > rainbows-5.0.0/lib/rainbows/response.rb:85:in `write_body_each' That is all correct. > Note that the rack spec specifically requires that body respond to > #each and yield a set of strings: > > https://github.com/rack/rack/blob/25a549883b85fb33970b4a1530a365c0c9e51f95/SPEC#L245-L248 Also correct. > So, it seems that the onus is likely on rainbows to conform to the > rack spec in order to require it's use. One solution would be to wrap > the bare string in an array before it descends into rack. Actually, I believe the onus is on the application to produce a correct response body for the application server to use. Testing your application with the Rack::Lint middleware enabled should've detected such an error. Application frameworks (e.g. Sinatra, Rails, etc) already produce a response body which responds to #each out-of-the-box. A brief scan of lib/rack/handlers/*.rb in rack.git reveals the server handlers bundled with rack itself expect the body to respond to #each, too.