From 74f50ace1c7092b876aff8da0fb37b6b7616b80b Mon Sep 17 00:00:00 2001 From: nakajijapan Date: Tue, 14 Jun 2016 23:25:57 +0900 Subject: [PATCH 1/2] return when file io is eof --- lib/httpclient/http.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/httpclient/http.rb b/lib/httpclient/http.rb index 10455050..c4d8d2de 100644 --- a/lib/httpclient/http.rb +++ b/lib/httpclient/http.rb @@ -574,6 +574,9 @@ def reset_pos(io) end def dump_file(io, dev, sz) + + return if io.eof? + buf = '' rest = sz while rest > 0 @@ -585,6 +588,7 @@ def dump_file(io, dev, sz) end def dump_chunks(io, dev) + buf = '' while !io.read(@chunk_size, buf).nil? dev << dump_chunk(buf) From ca6dfc5ae9c066c33ba7cd7412724b8aa1ebb60e Mon Sep 17 00:00:00 2001 From: nakajijapan Date: Tue, 14 Jun 2016 23:54:52 +0900 Subject: [PATCH 2/2] not error --- lib/httpclient/http.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/httpclient/http.rb b/lib/httpclient/http.rb index c4d8d2de..3b78c375 100644 --- a/lib/httpclient/http.rb +++ b/lib/httpclient/http.rb @@ -575,13 +575,11 @@ def reset_pos(io) def dump_file(io, dev, sz) - return if io.eof? - buf = '' rest = sz while rest > 0 n = io.read([rest, @chunk_size].min, buf) - raise ArgumentError.new("Illegal size value: #size returns #{sz} but cannot read") if n.nil? + return if n.nil? dev << buf rest -= n.bytesize end