diff options
Diffstat (limited to 'lib/rainbows/fiber/io.rb')
-rw-r--r-- | lib/rainbows/fiber/io.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/rainbows/fiber/io.rb b/lib/rainbows/fiber/io.rb index 5f925ca..d4f2512 100644 --- a/lib/rainbows/fiber/io.rb +++ b/lib/rainbows/fiber/io.rb @@ -8,6 +8,20 @@ module Rainbows # the underlying IO object cannot read or write class IO < Struct.new(:to_io, :f) + # :stopdoc: + LOCALHOST = Unicorn::HttpRequest::LOCALHOST + + # needed to write errors with + def write_nonblock(buf) + to_io.write_nonblock(buf) + end + + # enough for Rainbows.addr + def peeraddr + to_io.respond_to?(:peeraddr) ? to_io.peeraddr : [ LOCALHOST ] + end + # :stopdoc: + # for wrapping output response bodies def each(&block) begin @@ -24,6 +38,10 @@ module Rainbows to_io.close unless to_io.closed? end + def closed? + to_io.closed? + end + def wait_readable fileno = to_io.fileno RD[fileno] = self |