Sha256: add235c6667fd14e65518d7c55393e4663c89e6120eb452f0aa02d3cc0b14f1f

Contents?: true

Size: 782 Bytes

Versions: 1

Compression:

Stored size: 782 Bytes

Contents

require 'peddler/flat_file_response'
require 'peddler/xml_response'

module Peddler
  # @api private
  module Response
    # The inevitable messiness of massaging data produced by a motley army of
    # Amazon developers
    def self.new(response, encoding = 'ISO-8859-1')
      # Don't parse if there's no body
      return response unless response.body

      content_type = response.headers['Content-Type']
      if content_type.start_with?('text/xml')
        XMLResponse.new(response)
      else
        # Amazon returns a variety of content types for flat files, so we
        # simply assume that anything not XML is a flat file rather than code
        # defensively and check content type again.
        FlatFileResponse.new(response, encoding)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
peddler-0.12.7 lib/peddler/response.rb