Class: Aws::Plugins::StubResponses::Handler Private
- Inherits:
-
Seahorse::Client::Handler
- Object
- Seahorse::Client::Handler
- Aws::Plugins::StubResponses::Handler
- Defined in:
- lib/aws-sdk-core/plugins/stub_responses.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 Seahorse::Client::Handler
Instance Method Summary collapse
- #apply_stub(stub, response, async_mode = false) ⇒ Object private
- #call(context) ⇒ Object private
- #signal_error(error, http_resp) ⇒ Object private
- #signal_http(stub, http_resp, async_mode = false) ⇒ Object private
Methods inherited from Seahorse::Client::Handler
Constructor Details
This class inherits a constructor from Seahorse::Client::Handler
Instance Method Details
#apply_stub(stub, response, async_mode = false) ⇒ 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.
64 65 66 67 68 69 70 71 |
# File 'lib/aws-sdk-core/plugins/stub_responses.rb', line 64 def apply_stub(stub, response, async_mode = false) http_resp = response.context.http_response case when stub[:error] then signal_error(stub[:error], http_resp) when stub[:http] then signal_http(stub[:http], http_resp, async_mode) when stub[:data] then response.data = stub[:data] 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.
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/aws-sdk-core/plugins/stub_responses.rb', line 50 def call(context) stub = context.client.next_stub(context) resp = Seahorse::Client::Response.new(context: context) async_mode = context.client.is_a? Seahorse::Client::AsyncBase if Hash === stub && stub[:mutex] stub[:mutex].synchronize { apply_stub(stub, resp, async_mode) } else apply_stub(stub, resp, async_mode) end async_mode ? Seahorse::Client::AsyncResponse.new( context: context, stream: context[:input_event_stream_handler].event_emitter.stream, sync_queue: Queue.new) : resp end |
#signal_error(error, http_resp) ⇒ 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.
73 74 75 76 77 78 79 |
# File 'lib/aws-sdk-core/plugins/stub_responses.rb', line 73 def signal_error(error, http_resp) if Exception === error http_resp.signal_error(error) else http_resp.signal_error(error.new) end end |
#signal_http(stub, http_resp, async_mode = false) ⇒ 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.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/aws-sdk-core/plugins/stub_responses.rb', line 84 def signal_http(stub, http_resp, async_mode = false) if async_mode h2_headers = stub.headers.to_h.inject([]) do |arr, (k, v)| arr << [k, v] end h2_headers << [":status", stub.status_code] http_resp.signal_headers(h2_headers) else http_resp.signal_headers(stub.status_code, stub.headers.to_h) end while chunk = stub.body.read(1024 * 1024) http_resp.signal_data(chunk) end stub.body.rewind http_resp.signal_done end |