From 4b7ffee7c2436b1839146fd124e731a63f20d03e Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 18 Oct 2013 17:54:43 +0000 Subject: remove tiny_input Since we are smarter about closing @input, we can just call .close on it as closing inputs is forbidden in Rack apps, anyways. This reduces our class count and should make things easier to follow. --- lib/yahns/http_client.rb | 1 - lib/yahns/http_context.rb | 3 +-- lib/yahns/http_response.rb | 2 +- lib/yahns/stream_input.rb | 2 +- lib/yahns/tee_input.rb | 2 +- lib/yahns/tiny_input.rb | 7 ------- 6 files changed, 4 insertions(+), 13 deletions(-) delete mode 100644 lib/yahns/tiny_input.rb diff --git a/lib/yahns/http_client.rb b/lib/yahns/http_client.rb index 3ee6011..198c130 100644 --- a/lib/yahns/http_client.rb +++ b/lib/yahns/http_client.rb @@ -1,7 +1,6 @@ # -*- encoding: binary -*- # Copyright (C) 2013, Eric Wong and all contributors # 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 = StringIO.new("") diff --git a/lib/yahns/http_context.rb b/lib/yahns/http_context.rb index 1af41df..97a0f82 100644 --- a/lib/yahns/http_context.rb +++ b/lib/yahns/http_context.rb @@ -1,7 +1,6 @@ # -*- encoding: binary -*- # Copyright (C) 2013, Eric Wong and all contributors # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt) -require 'yahns/tiny_input' # subclasses of Yahns::HttpClient will class extend this @@ -61,6 +60,6 @@ module Yahns::HttpContext # :nodoc: def tmpio_for(len) len && len <= @client_body_buffer_size ? - Yahns::TinyInput.new("") : Yahns::TmpIO.new + StringIO.new("") : Yahns::TmpIO.new end end diff --git a/lib/yahns/http_response.rb b/lib/yahns/http_response.rb index aad2762..8967670 100644 --- a/lib/yahns/http_response.rb +++ b/lib/yahns/http_response.rb @@ -64,7 +64,7 @@ module Yahns::HttpResponse # :nodoc: end def http_response_done(alive) - @input = @input.discard if @input + @input = @input.close if @input if alive @response_start_sent = false # @hs.buf will have data if the client pipelined diff --git a/lib/yahns/stream_input.rb b/lib/yahns/stream_input.rb index f0a43b3..8bef95e 100644 --- a/lib/yahns/stream_input.rb +++ b/lib/yahns/stream_input.rb @@ -145,6 +145,6 @@ class Yahns::StreamInput # :nodoc: raise Yahns::ClientShutdown, "bytes_read=#{@bytes_read}", [] end - def discard # return nil + def close # return nil end end diff --git a/lib/yahns/tee_input.rb b/lib/yahns/tee_input.rb index 0d91a89..9028a6e 100644 --- a/lib/yahns/tee_input.rb +++ b/lib/yahns/tee_input.rb @@ -108,7 +108,7 @@ class Yahns::TeeInput < Yahns::StreamInput # :nodoc: buffer end - def discard + def close # returns nil @tmp = @tmp.close end end diff --git a/lib/yahns/tiny_input.rb b/lib/yahns/tiny_input.rb deleted file mode 100644 index 55bdd03..0000000 --- a/lib/yahns/tiny_input.rb +++ /dev/null @@ -1,7 +0,0 @@ -# -*- encoding: binary -*- -# Copyright (C) 2013, Eric Wong et. al. -# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt) -class Yahns::TinyInput < StringIO # :nodoc: - def discard # just returns nil - end -end -- cgit v1.2.3-24-ge0c7