Sha256: 1e1e0189de6639101d665e1fb86e75f7d210eb16ba9d2aff1c19388dbb96da07

Contents?: true

Size: 1.09 KB

Versions: 10

Compression:

Stored size: 1.09 KB

Contents

module Seahorse
  module Client
    module Http
      class Response

        # @option options [Integer] :status_code (0)
        # @option options [Headers] :headers (Headers.new)
        # @option options [IO] :body (StringIO.new)
        def initialize(options = {})
          @status_code = options[:status_code] || 0
          @headers = options[:headers] || Headers.new
          @body = options[:body] || PlainStringIO.new
        end

        # @return [Integer] Returns `0` if the request failed to generate
        #   any response.
        attr_accessor :status_code

        # @return [Headers]
        attr_accessor :headers

        # @return [IO]
        attr_accessor :body

        # @param [#read, #size, #rewind] io
        def body=(io)
          @body = case io
            when nil then PlainStringIO.new('')
            when String then PlainStringIO.new(io)
            else io
          end
        end

        # @return [String]
        def body_contents
          body.rewind
          contents = body.read
          body.rewind
          contents
        end

      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
aws-sdk-core-2.0.0.rc10 vendor/seahorse/lib/seahorse/client/http/response.rb
aws-sdk-core-2.0.0.rc9 vendor/seahorse/lib/seahorse/client/http/response.rb
aws-sdk-core-2.0.0.rc8 vendor/seahorse/lib/seahorse/client/http/response.rb
aws-sdk-core-2.0.0.rc7 vendor/seahorse/lib/seahorse/client/http/response.rb
aws-sdk-core-2.0.0.rc6 vendor/seahorse/lib/seahorse/client/http/response.rb
aws-sdk-core-2.0.0.rc5 vendor/seahorse/lib/seahorse/client/http/response.rb
aws-sdk-core-2.0.0.rc4 vendor/seahorse/lib/seahorse/client/http/response.rb
aws-sdk-core-2.0.0.rc3 vendor/seahorse/lib/seahorse/client/http/response.rb
aws-sdk-core-2.0.0.rc2 vendor/seahorse/lib/seahorse/client/http/response.rb
aws-sdk-core-2.0.0.rc1 vendor/seahorse/lib/seahorse/client/http/response.rb