From: Eric Wong <normalperson-rMlxZR9MS24@public.gmane.org>
To: lmgtwty-TBHja+091Wbby3iVrkZq2A@public.gmane.org,
rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org
Subject: [PATCH] env["hack.io"] for Fiber*, Revactor, Thread* models
Date: Fri, 11 Dec 2009 03:59:05 -0800 [thread overview]
Message-ID: <20091211115905.GA15621@dcvr.yhbt.net> (raw)
In-Reply-To: <20091211115348.GB14610-yBiyF41qdooeIZ0/mPfg9Q@public.gmane.org>
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
next prev parent reply other threads:[~2009-12-11 11:59 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-11 11:50 [ANN] LMGTWTY: Web Sockets Library for Rack+Rainbows! Eric Wong
[not found] ` <20091211115041.GA14610-yBiyF41qdooeIZ0/mPfg9Q@public.gmane.org>
2009-12-11 11:53 ` Eric Wong
[not found] ` <20091211115348.GB14610-yBiyF41qdooeIZ0/mPfg9Q@public.gmane.org>
2009-12-11 11:59 ` Eric Wong [this message]
[not found] ` <20091211115905.GA15621-yBiyF41qdooeIZ0/mPfg9Q@public.gmane.org>
2009-12-13 13:47 ` [PATCH] env["hack.io"] for Fiber*, Revactor, Thread* models James Tucker
[not found] ` <D3B4FD37-50B9-4913-88E3-92C1B1877ED8-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2009-12-13 19:45 ` Eric Wong
[not found] ` <20091213194553.GC19572-yBiyF41qdooeIZ0/mPfg9Q@public.gmane.org>
2009-12-13 21:25 ` James Tucker
2009-12-13 20:50 ` [ANN] LMGTWTY: Web Sockets Library for Rack+Rainbows! Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://yhbt.net/rainbows/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20091211115905.GA15621@dcvr.yhbt.net \
--to=normalperson-rmlxzr9ms24@public.gmane.org \
--cc=lmgtwty-TBHja+091Wbby3iVrkZq2A@public.gmane.org \
--cc=rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhbt.net/rainbows.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).