Class: Seahorse::Client::Plugins::RequestCallback::OptionHandler Private
- Defined in:
- lib/seahorse/client/plugins/request_callback.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Attribute Summary
Attributes inherited from Handler
Instance Method Summary collapse
Methods inherited from Handler
Constructor Details
This class inherits a constructor from Seahorse::Client::Handler
Instance Method Details
#add_response_events(on_chunk_received, context) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/seahorse/client/plugins/request_callback.rb', line 92 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 |
#call(context) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/seahorse/client/plugins/request_callback.rb', line 75 def call(context) if context.params.is_a?(Hash) && context.params[:on_chunk_sent] on_chunk_sent = context.params.delete(:on_chunk_sent) end on_chunk_sent = context.config.on_chunk_sent if on_chunk_sent.nil? context[:on_chunk_sent] = on_chunk_sent if on_chunk_sent if context.params.is_a?(Hash) && context.params[:on_chunk_received] on_chunk_received = context.params.delete(:on_chunk_received) end on_chunk_received = context.config.on_chunk_received if on_chunk_received.nil? add_response_events(on_chunk_received, context) if on_chunk_received @handler.call(context) end |