From dfc5f5a5e4aec4578b79de68c91906da75472a5a Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 29 Sep 2010 23:57:57 -0700 Subject: tee_input: update interface to use HttpRequest This should ensure we have less typing to do. --- lib/unicorn/http_request.rb | 4 +++- lib/unicorn/tee_input.rb | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/unicorn/http_request.rb b/lib/unicorn/http_request.rb index 8abc945..c12f721 100644 --- a/lib/unicorn/http_request.rb +++ b/lib/unicorn/http_request.rb @@ -21,6 +21,8 @@ module Unicorn NULL_IO = StringIO.new("") LOCALHOST = '127.0.0.1' + attr_reader :env, :parser, :buf + def initialize @parser = Unicorn::HttpParser.new @buf = "" @@ -67,7 +69,7 @@ module Unicorn end while @parser.headers(@env, @buf).nil? end @env[Const::RACK_INPUT] = 0 == @parser.content_length ? - NULL_IO : Unicorn::TeeInput.new(socket, @env, @parser, @buf) + NULL_IO : Unicorn::TeeInput.new(socket, self) @env.merge!(DEFAULTS) end end diff --git a/lib/unicorn/tee_input.rb b/lib/unicorn/tee_input.rb index 540cfe0..7e508fc 100644 --- a/lib/unicorn/tee_input.rb +++ b/lib/unicorn/tee_input.rb @@ -25,8 +25,11 @@ class Unicorn::TeeInput < Struct.new(:socket, :req, :parser, # Initializes a new TeeInput object. You normally do not have to call # this unless you are writing an HTTP server. - def initialize(*args) - super(*args) + def initialize(socket, request) + self.socket = socket + self.req = request.env + self.parser = request.parser + self.buf = request.buf self.len = parser.content_length self.tmp = len && len < @@client_body_buffer_size ? StringIO.new("") : Unicorn::Util.tmpio -- cgit v1.2.3-24-ge0c7