From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: * X-Spam-ASN: AS14383 205.234.109.0/24 X-Spam-Status: No, score=1.0 required=3.0 tests=AWL,HK_RANDOM_FROM, MSGID_FROM_MTA_HEADER shortcircuit=no autolearn=no version=3.3.2 Path: news.gmane.org!not-for-mail From: Eric Wong Newsgroups: gmane.comp.lang.ruby.rainbows.general Subject: [PATCH] env["hack.io"] for Fiber*, Revactor, Thread* models Date: Fri, 11 Dec 2009 03:59:05 -0800 Message-ID: <20091211115905.GA15621@dcvr.yhbt.net> References: <20091211115041.GA14610@dcvr.yhbt.net> <20091211115348.GB14610@dcvr.yhbt.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1260532760 6972 80.91.229.12 (11 Dec 2009 11:59:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 11 Dec 2009 11:59:20 +0000 (UTC) To: lmgtwty-TBHja+091Wbby3iVrkZq2A@public.gmane.org, rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Original-X-From: rainbows-talk-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Fri Dec 11 12:59:13 2009 Return-path: Envelope-to: gclrrg-rainbows-talk@m.gmane.org X-Original-To: rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Delivered-To: rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Content-Disposition: inline In-Reply-To: <20091211115348.GB14610-yBiyF41qdooeIZ0/mPfg9Q@public.gmane.org> User-Agent: Mutt/1.5.18 (2008-05-17) X-BeenThere: rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: rainbows-talk-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Errors-To: rainbows-talk-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Xref: news.gmane.org gmane.comp.lang.ruby.rainbows.general:43 Archived-At: Received: from rubyforge.org ([205.234.109.19]) by lo.gmane.org with esmtp (Exim 4.50) id 1NJ49Q-0006zt-0N for gclrrg-rainbows-talk@m.gmane.org; Fri, 11 Dec 2009 12:59:12 +0100 Received: from rubyforge.org (rubyforge.org [127.0.0.1]) by rubyforge.org (Postfix) with ESMTP id CE3EE18582C9; Fri, 11 Dec 2009 06:59:11 -0500 (EST) Received: from dcvr.yhbt.net (dcvr.yhbt.net [64.71.152.64]) by rubyforge.org (Postfix) with ESMTP id 767C418582C9 for ; Fri, 11 Dec 2009 06:59:06 -0500 (EST) Received: from localhost (unknown [127.0.2.5]) by dcvr.yhbt.net (Postfix) with ESMTP id CB5C11F605; Fri, 11 Dec 2009 11:59:05 +0000 (UTC) This exposes a client IO object directly to the underlying application. --- In case you already have an installation and just want to patch that, this is the patch I made for Rainbows! that exposes the ability to be used with LMGTWTY lib/rainbows/base.rb | 1 + lib/rainbows/const.rb | 6 ++++++ lib/rainbows/fiber/base.rb | 1 + lib/rainbows/revactor.rb | 1 + 4 files changed, 9 insertions(+), 0 deletions(-) diff --git a/lib/rainbows/base.rb b/lib/rainbows/base.rb index 424b43b..a735b82 100644 --- a/lib/rainbows/base.rb +++ b/lib/rainbows/base.rb @@ -43,6 +43,7 @@ module Rainbows buf << client.readpartial(CHUNK_SIZE) end + env[CLIENT_IO] = client env[RACK_INPUT] = 0 == hp.content_length ? HttpRequest::NULL_IO : Unicorn::TeeInput.new(client, env, hp, buf) diff --git a/lib/rainbows/const.rb b/lib/rainbows/const.rb index 69e58aa..900c9d9 100644 --- a/lib/rainbows/const.rb +++ b/lib/rainbows/const.rb @@ -19,5 +19,11 @@ module Rainbows CONN_ALIVE = "Connection: keep-alive\r\n" LOCALHOST = "127.0.0.1" + # client IO object that supports reading and writing directly + # without filtering it through the HTTP chunk parser. + # Maybe we can get this renamed to "rack.io" if it becomes part + # of the official spec, but for now it is "hack.io" + CLIENT_IO = "hack.io".freeze + end end diff --git a/lib/rainbows/fiber/base.rb b/lib/rainbows/fiber/base.rb index 129448c..995b4af 100644 --- a/lib/rainbows/fiber/base.rb +++ b/lib/rainbows/fiber/base.rb @@ -82,6 +82,7 @@ module Rainbows buf << (client.read_timeout or return) end + env[CLIENT_IO] = client env[RACK_INPUT] = 0 == hp.content_length ? HttpRequest::NULL_IO : TeeInput.new(client, env, hp, buf) env[REMOTE_ADDR] = remote_addr diff --git a/lib/rainbows/revactor.rb b/lib/rainbows/revactor.rb index b647d48..ff0e429 100644 --- a/lib/rainbows/revactor.rb +++ b/lib/rainbows/revactor.rb @@ -49,6 +49,7 @@ module Rainbows buf << client.read(*rd_args) end + env[Const::CLIENT_IO] = client env[Const::RACK_INPUT] = 0 == hp.content_length ? HttpRequest::NULL_IO : Rainbows::Revactor::TeeInput.new(client, env, hp, buf) -- Eric Wong _______________________________________________ Rainbows! mailing list - rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org http://rubyforge.org/mailman/listinfo/rainbows-talk Do not quote signatures (like this one) or top post when replying