Sha256: a15e64209dfd2230934def20cc1f9e6192df60aa7f4a90a9e1a5e34b2a9f85b2

Contents?: true

Size: 1.12 KB

Versions: 79

Compression:

Stored size: 1.12 KB

Contents

module Seahorse
  module Client
    module Http
      class AsyncResponse < Seahorse::Client::Http::Response

        def initialize(options = {})
          super
        end

        def signal_headers(headers)
          # H2 headers arrive as array of pair
          hash = headers.inject({}) do |h, pair|
            key, value = pair
            h[key] = value
            h
          end
          @status_code = hash[":status"].to_i
          @headers = Headers.new(hash)
          emit(:headers, @status_code, @headers)
        end

        def signal_done(options = {})
          # H2 only has header and body
          # ':status' header will be sent back
          if options.keys.sort == [:body, :headers]
            signal_headers(options[:headers])
            signal_data(options[:body])
            signal_done
          elsif options.empty?
            @body.rewind if @body.respond_to?(:rewind)
            @done = true
            emit(:done)
          else
            msg = "options must be empty or must contain :headers and :body"
            raise ArgumentError, msg
          end
        end

      end
    end
  end
end

Version data entries

79 entries across 79 versions & 1 rubygems

Version Path
aws-sdk-core-3.100.0 lib/seahorse/client/http/async_response.rb
aws-sdk-core-3.99.2 lib/seahorse/client/http/async_response.rb
aws-sdk-core-3.99.1 lib/seahorse/client/http/async_response.rb
aws-sdk-core-3.99.0 lib/seahorse/client/http/async_response.rb
aws-sdk-core-3.98.0 lib/seahorse/client/http/async_response.rb
aws-sdk-core-3.97.1 lib/seahorse/client/http/async_response.rb
aws-sdk-core-3.97.0 lib/seahorse/client/http/async_response.rb
aws-sdk-core-3.96.1 lib/seahorse/client/http/async_response.rb
aws-sdk-core-3.96.0 lib/seahorse/client/http/async_response.rb
aws-sdk-core-3.95.0 lib/seahorse/client/http/async_response.rb
aws-sdk-core-3.94.1 lib/seahorse/client/http/async_response.rb
aws-sdk-core-3.94.0 lib/seahorse/client/http/async_response.rb
aws-sdk-core-3.93.0 lib/seahorse/client/http/async_response.rb
aws-sdk-core-3.92.0 lib/seahorse/client/http/async_response.rb
aws-sdk-core-3.91.1 lib/seahorse/client/http/async_response.rb
aws-sdk-core-3.91.0 lib/seahorse/client/http/async_response.rb
aws-sdk-core-3.90.1 lib/seahorse/client/http/async_response.rb
aws-sdk-core-3.90.0 lib/seahorse/client/http/async_response.rb
aws-sdk-core-3.89.1 lib/seahorse/client/http/async_response.rb
aws-sdk-core-3.89.0 lib/seahorse/client/http/async_response.rb