Class: Seahorse::Client::Plugins::RequestCallback::ReadCallbackHandler Private

Inherits:
Handler
  • Object
show all
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

#handler

Instance Method Summary collapse

Methods inherited from Handler

#initialize, #inspect

Constructor Details

This class inherits a constructor from Seahorse::Client::Handler

Instance Method Details

#add_event_listeners(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.


88
89
90
91
92
93
94
95
96
# File 'lib/seahorse/client/plugins/request_callback.rb', line 88

def add_event_listeners(context)
  # unwrap the request body as soon as we start receiving a response
  context.http_response.on_headers do
    body = context.http_request.body
    if body.is_a? ReadCallbackIO
      context.http_request.body = body.io
    end
  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.


77
78
79
80
81
82
83
84
85
86
# File 'lib/seahorse/client/plugins/request_callback.rb', line 77

def call(context)
  if (callback = context[:on_chunk_sent])
    context.http_request.body = ReadCallbackIO.new(
      context.http_request.body,
      callback
    )
    add_event_listeners(context)
  end
  @handler.call(context)
end