Sha256: 0051d003ad50094468ffd42cf4b61e58fa1e1daa06757fe70bb1ff987c8ec1d0

Contents?: true

Size: 1.15 KB

Versions: 190

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

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

190 entries across 190 versions & 1 rubygems

Version Path
aws-sdk-core-3.180.1 lib/seahorse/client/http/async_response.rb
aws-sdk-core-3.180.0 lib/seahorse/client/http/async_response.rb
aws-sdk-core-3.179.0 lib/seahorse/client/http/async_response.rb
aws-sdk-core-3.178.0 lib/seahorse/client/http/async_response.rb
aws-sdk-core-3.177.0 lib/seahorse/client/http/async_response.rb
aws-sdk-core-3.176.1 lib/seahorse/client/http/async_response.rb
aws-sdk-core-3.176.0 lib/seahorse/client/http/async_response.rb
aws-sdk-core-3.175.0 lib/seahorse/client/http/async_response.rb
aws-sdk-core-3.174.0 lib/seahorse/client/http/async_response.rb
aws-sdk-core-3.173.1 lib/seahorse/client/http/async_response.rb
aws-sdk-core-3.173.0 lib/seahorse/client/http/async_response.rb
aws-sdk-core-3.172.0 lib/seahorse/client/http/async_response.rb
aws-sdk-core-3.171.1 lib/seahorse/client/http/async_response.rb
aws-sdk-core-3.171.0 lib/seahorse/client/http/async_response.rb
aws-sdk-core-3.170.1 lib/seahorse/client/http/async_response.rb
aws-sdk-core-3.170.0 lib/seahorse/client/http/async_response.rb
aws-sdk-core-3.169.0 lib/seahorse/client/http/async_response.rb
aws-sdk-core-3.168.4 lib/seahorse/client/http/async_response.rb
aws-sdk-core-3.168.3 lib/seahorse/client/http/async_response.rb
aws-sdk-core-3.168.2 lib/seahorse/client/http/async_response.rb