diff options
Diffstat (limited to 'lib/yahns')
-rw-r--r-- | lib/yahns/http_client.rb | 2 | ||||
-rw-r--r-- | lib/yahns/http_context.rb | 17 |
2 files changed, 11 insertions, 8 deletions
diff --git a/lib/yahns/http_client.rb b/lib/yahns/http_client.rb index 109b545..c300742 100644 --- a/lib/yahns/http_client.rb +++ b/lib/yahns/http_client.rb @@ -3,7 +3,7 @@ # License: GPL-3.0+ (https://www.gnu.org/licenses/gpl-3.0.txt) # frozen_string_literal: true class Yahns::HttpClient < Kgio::Socket # :nodoc: - NULL_IO = StringIO.new.binmode # :nodoc: + NULL_IO = StringIO.new(''.dup) # :nodoc: include Yahns::HttpResponse QEV_FLAGS = Yahns::Queue::QEV_RD # used by acceptor diff --git a/lib/yahns/http_context.rb b/lib/yahns/http_context.rb index c7258ad..10be062 100644 --- a/lib/yahns/http_context.rb +++ b/lib/yahns/http_context.rb @@ -80,13 +80,16 @@ module Yahns::HttpContext # :nodoc: def tmpio_for(len, env) # short requests are most common - return StringIO.new.binmode if len && len <= @client_body_buffer_size; - - # too big or chunked, unknown length - tmp = @input_buffer_tmpdir - mbs = @client_max_body_size - tmp = mbs ? Yahns::CapInput.new(mbs, tmp) : Yahns::TmpIO.new(tmp) - (env['rack.tempfiles'] ||= []) << tmp + if len && len <= @client_body_buffer_size; + # Can't use binmode, yet: https://bugs.ruby-lang.org/issues/11945 + tmp = StringIO.new + tmp.set_encoding(Encoding::ASCII_8BIT) + else # too big or chunked, unknown length + tmp = @input_buffer_tmpdir + mbs = @client_max_body_size + tmp = mbs ? Yahns::CapInput.new(mbs, tmp) : Yahns::TmpIO.new(tmp) + (env['rack.tempfiles'] ||= []) << tmp + end tmp end end |