./lib/animoto/http_engines/curl_adapter.rb in animoto-1.0.0 vs ./lib/animoto/http_engines/curl_adapter.rb in animoto-1.1.0
- old
+ new
@@ -6,12 +6,11 @@
# @return [String]
def request method, url, body = nil, headers = {}, options = {}
curl = build_curl method, url, body, headers, options
perform curl, method, body
- check_response curl.response_code, curl.body_str
- curl.body_str
+ [curl.response_code, curl.body_str]
end
private
# Creates a Curl::Easy object with the headers, options, body, etc. set.
@@ -21,14 +20,18 @@
# @param [String,nil] body the request body
# @param [Hash{String=>String}] headers hash of HTTP request headers
# @return [Curl::Easy] the Easy instance
def build_curl method, url, body, headers, options
::Curl::Easy.new(url) do |c|
+ c.http_auth_types = Curl::CURLAUTH_BASIC
c.username = options[:username]
c.password = options[:password]
c.timeout = options[:timeout]
c.post_body = body
+ c.ssl_verify_host = false
+ c.ssl_verify_peer = false
+ c.proxy_url = options[:proxy]
headers.each { |header, value| c.headers[header] = value }
end
end
# Performs the request.
@@ -37,13 +40,19 @@
# @param [Symbol] method the HTTP method to use
# @param [String] body the HTTP request body
# @return [void]
def perform curl, method, body
case method
+ when :head
+ curl.http_head
when :get
curl.http_get
when :post
curl.http_post(body)
+ when :put
+ curl.http_put(body)
+ when :delete
+ curl.http_delete
end
end
end
end
end
\ No newline at end of file