File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change 9
9
#
10
10
# $IPR: httprequest.rb,v 1.64 2003/07/13 17:18:22 gotoyuzo Exp $
11
11
12
+ require 'fiber'
12
13
require 'uri'
13
14
require_relative 'httpversion'
14
15
require_relative 'httpstatus'
@@ -273,13 +274,17 @@ def body_reader
273
274
self
274
275
end
275
276
276
- # for IO.copy_stream. Note: we may return a larger string than +size+
277
- # here; but IO.copy_stream does not care.
277
+ # for IO.copy_stream.
278
278
def readpartial ( size , buf = '' . b ) # :nodoc
279
279
res = @body_tmp . shift or raise EOFError , 'end of file reached'
280
+ if res . length > size
281
+ @body_tmp . unshift ( res [ size ..-1 ] )
282
+ res = res [ 0 ..size - 1 ]
283
+ end
280
284
buf . replace ( res )
281
285
res . clear
282
- @body_rd . resume # get more chunks
286
+ # get more chunks - check alive? because we can take a partial chunk
287
+ @body_rd . resume if @body_rd . alive?
283
288
buf
284
289
end
285
290
You can’t perform that action at this time.
0 commit comments