class Seahorse::Client::Plugins::RequestCallback::OptionHandler

def add_response_events(on_chunk_received, context)

def add_response_events(on_chunk_received, context)
  shared_data = {bytes_received: 0}
  context.http_response.on_headers do |_status, headers|
    shared_data[:content_length] = headers['content-length']&.to_i
  end
  context.http_response.on_data do |chunk|
    shared_data[:bytes_received] += chunk.bytesize if chunk && chunk.respond_to?(:bytesize)
    on_chunk_received.call(chunk, shared_data[:bytes_received], shared_data[:content_length])
  end
end