Module: HTTPX::Plugins::Stream::ResponseBodyMethods

Defined in:
lib/httpx/plugins/stream.rb

Instance Method Summary collapse

Instance Method Details

#initializeObject



129
130
131
132
# File 'lib/httpx/plugins/stream.rb', line 129

def initialize(*)
  super
  @stream = @response.stream
end

#write(chunk) ⇒ Object



134
135
136
137
138
139
140
141
142
143
144
# File 'lib/httpx/plugins/stream.rb', line 134

def write(chunk)
  return super unless @stream

  return 0 if chunk.empty?

  chunk = decode_chunk(chunk)

  @stream.on_chunk(chunk.dup)

  chunk.size
end