Method: HTTP::Connection#readpartial

Defined in:
lib/http/connection.rb

#readpartial(size = BUFFER_SIZE) ⇒ String?

Read a chunk of the body

Returns:

  • (String)

    data chunk

  • (nil)

    when no more data left



93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/http/connection.rb', line 93

def readpartial(size = BUFFER_SIZE)
  return unless @pending_response

  chunk = @parser.read(size)
  return chunk if chunk

  finished = (read_more(size) == :eof) || @parser.finished?
  chunk    = @parser.read(size)
  finish_response if finished

  chunk || "".b
end