Sha256: b446e4033beac374ff7ca1661e24ba6d58057107213873df336c787a19969bcd

Contents?: true

Size: 1.35 KB

Versions: 24

Compression:

Stored size: 1.35 KB

Contents

# frozen_string_literal: true

module Aws
  module Binary

    # @api private
    class DecodeHandler < Seahorse::Client::Handler

      def call(context)
        if eventstream_member = eventstream?(context)
          attach_eventstream_listeners(context, eventstream_member)
        end
        @handler.call(context)
      end

      private

      def eventstream?(ctx)
        ctx.operation.output.shape.members.each do |_, ref|
          return ref if ref.eventstream
        end
      end

      def attach_eventstream_listeners(context, rules)
        context.http_response.on_headers(200) do
          output_handler = context[:output_event_stream_handler] ||
                           context[:event_stream_handler]
          context.http_response.body = EventStreamDecoder.new(
            context.config.protocol,
            rules,
            context.operation.output,
            context.operation.errors,
            context.http_response.body,
            output_handler)
        end

        context.http_response.on_success(200) do
          context.http_response.body = context.http_response.body.events
        end

        context.http_response.on_error do
          # Potential enhancement to made
          # since we don't want to track raw bytes in memory
          context.http_response.body = StringIO.new
        end

      end

    end

  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
aws-sdk-core-3.214.0 lib/aws-sdk-core/binary/decode_handler.rb
aws-sdk-core-3.213.0 lib/aws-sdk-core/binary/decode_handler.rb
aws-sdk-core-3.212.0 lib/aws-sdk-core/binary/decode_handler.rb
aws-sdk-core-3.211.0 lib/aws-sdk-core/binary/decode_handler.rb
aws-sdk-core-3.210.0 lib/aws-sdk-core/binary/decode_handler.rb
aws-sdk-core-3.209.1 lib/aws-sdk-core/binary/decode_handler.rb
aws-sdk-core-3.209.0 lib/aws-sdk-core/binary/decode_handler.rb
aws-sdk-core-3.208.0 lib/aws-sdk-core/binary/decode_handler.rb
aws-sdk-core-3.207.0 lib/aws-sdk-core/binary/decode_handler.rb
aws-sdk-core-3.206.0 lib/aws-sdk-core/binary/decode_handler.rb
aws-sdk-core-3.205.0 lib/aws-sdk-core/binary/decode_handler.rb
aws-sdk-core-3.204.0 lib/aws-sdk-core/binary/decode_handler.rb
aws-sdk-core-3.203.0 lib/aws-sdk-core/binary/decode_handler.rb
aws-sdk-core-3.202.2 lib/aws-sdk-core/binary/decode_handler.rb
aws-sdk-core-3.202.1 lib/aws-sdk-core/binary/decode_handler.rb
aws-sdk-core-3.202.0 lib/aws-sdk-core/binary/decode_handler.rb
aws-sdk-core-3.201.5 lib/aws-sdk-core/binary/decode_handler.rb
aws-sdk-core-3.201.4 lib/aws-sdk-core/binary/decode_handler.rb
aws-sdk-core-3.201.3 lib/aws-sdk-core/binary/decode_handler.rb
aws-sdk-core-3.201.2 lib/aws-sdk-core/binary/decode_handler.rb