about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2013-10-18 17:54:43 +0000
committerEric Wong <normalperson@yhbt.net>2013-10-18 17:54:43 +0000
commit4b7ffee7c2436b1839146fd124e731a63f20d03e (patch)
treea036099c5b9b36e71e2fe6482b2059f7f4b5341a
parentec8bb4033257fd36ca93ba746c41abc1bd0175b6 (diff)
downloadyahns-4b7ffee7c2436b1839146fd124e731a63f20d03e.tar.gz
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.
-rw-r--r--lib/yahns/http_client.rb1
-rw-r--r--lib/yahns/http_context.rb3
-rw-r--r--lib/yahns/http_response.rb2
-rw-r--r--lib/yahns/stream_input.rb2
-rw-r--r--lib/yahns/tee_input.rb2
-rw-r--r--lib/yahns/tiny_input.rb7
6 files changed, 4 insertions, 13 deletions
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 <normalperson@yhbt.net> 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 <normalperson@yhbt.net> 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 <normalperson@yhbt.net> 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