lib/active_merchant/common/connection.rb in activemerchant-1.13.0 vs lib/active_merchant/common/connection.rb in activemerchant-1.14.0
- old
+ new
@@ -39,17 +39,19 @@
attr_accessor :pem
attr_accessor :pem_password
attr_accessor :wiredump_device
attr_accessor :logger
attr_accessor :tag
+ attr_accessor :ignore_http_status
def initialize(endpoint)
@endpoint = endpoint.is_a?(URI) ? endpoint : URI.parse(endpoint)
@open_timeout = OPEN_TIMEOUT
@read_timeout = READ_TIMEOUT
@retry_safe = RETRY_SAFE
@verify_peer = VERIFY_PEER
+ @ignore_http_status = false
end
def request(method, body, headers = {})
retry_exceptions do
begin
@@ -141,9 +143,22 @@
raise ConnectionError, e.message
rescue ConnectionError
retries -= 1
retry if retry_safe && !retries.zero?
raise
+ end
+ end
+
+ def handle_response(response)
+ if @ignore_http_status then
+ return response.body
+ else
+ case response.code.to_i
+ when 200...300
+ response.body
+ else
+ raise ResponseError.new(response)
+ end
end
end
def debug(message, tag = nil)
log(:debug, message, tag)