From 69650f8f09fca2c7df3230e2bf054961a5292e52 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 18 Aug 2009 11:59:16 -0700 Subject: tee_input: allow using Revactor::TCP::Socket objects The Revactor::TCP::Socket#read method without any arguments is more or less equivalent to TCPSocket#readpartial without an explicit buffer. Since we rely on the buffer being modified/replaced, monkey patch that object it to replace the buffer with our own since we rely on modifying the existing buffer passed to us. --- lib/unicorn/tee_input.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/unicorn/tee_input.rb b/lib/unicorn/tee_input.rb index fcf4a95..aa1dff3 100644 --- a/lib/unicorn/tee_input.rb +++ b/lib/unicorn/tee_input.rb @@ -23,6 +23,13 @@ module Unicorn @tmp.write(@buf2) @tmp.seek(0) end + + # give our socket object a readpartial if it can't handle it + if socket && ! socket.respond_to?(:readpartial) + def socket.readpartial(nr, buf = Unicorn::Z.dup) + buf.replace(read) + end + end end # returns the size of the input. This is what the Content-Length -- cgit v1.2.3-24-ge0c7