From ec8bb4033257fd36ca93ba746c41abc1bd0175b6 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 18 Oct 2013 17:52:35 +0000 Subject: http_client: do not set @input if it is NULL_IO That is the common case, so we should not be calling the discard method on NULL_IO. This makes NULL_IO a StringIO, again. --- lib/yahns/http_client.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/yahns/http_client.rb b/lib/yahns/http_client.rb index ff6e203..3ee6011 100644 --- a/lib/yahns/http_client.rb +++ b/lib/yahns/http_client.rb @@ -3,7 +3,7 @@ # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt) require 'yahns/tiny_input' class Yahns::HttpClient < Kgio::Socket # :nodoc: - NULL_IO = Yahns::TinyInput.new("") + NULL_IO = StringIO.new("") # FIXME: we shouldn't have this at all Unicorn::HttpParser.keepalive_requests = 0xffffffff @@ -66,7 +66,7 @@ class Yahns::HttpClient < Kgio::Socket # :nodoc: mkinput_preread # keep looping false else # :lazy, false - empty_body ? NULL_IO : k.mkinput(self, @hs) + empty_body ? NULL_IO : (@input = k.mkinput(self, @hs)) end end @@ -141,7 +141,7 @@ class Yahns::HttpClient < Kgio::Socket # :nodoc: env = @hs.env env[REMOTE_ADDR] = @kgio_addr env[RACK_HIJACK] = hijack_proc(env) - env[RACK_INPUT] = @input ||= input + env[RACK_INPUT] = input k = self.class if k.check_client_connection && @hs.headers? -- cgit v1.2.3-24-ge0c7