0
@@ -88,13 +88,10 @@ module HTTParty
0
- @http = Net::HTTP.new(uri.host, uri.port, @http_proxyaddr, @http_proxyport)
0
- @http.use_ssl = (uri.port == 443)
0
- # so we can avoid ssl warnings
0
- @http.verify_mode = OpenSSL::SSL::VERIFY_NONE
0
+ http = Net::HTTP.new(uri.host, uri.port, @http_proxyaddr, @http_proxyport)
0
+ http.use_ssl = (uri.port == 443)
0
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
0
# FIXME: this method is doing way to much and needs to be split up
0
@@ -107,10 +104,12 @@ module HTTParty
0
def send_request(method, path, options={}) #:nodoc:
0
options = {:limit => 5}.merge(options)
0
options[:limit] = 0 if options.delete(:no_follow)
0
raise HTTParty::RedirectionTooDeep, 'HTTP redirects too deep' if options[:limit].to_i <= 0
0
raise ArgumentError, 'only get, post, put and delete methods are supported' unless %w[get post put delete].include?(method.to_s)
0
raise ArgumentError, ':headers must be a hash' if options[:headers] && !options[:headers].is_a?(Hash)
0
raise ArgumentError, ':basic_auth must be a hash' if options[:basic_auth] && !options[:basic_auth].is_a?(Hash)
0
uri = path.relative? ? URI.parse("#{base_uri}#{path}") : path
0
existing_query = uri.query ? "#{uri.query}&" : ''
0
@@ -119,12 +118,12 @@ module HTTParty
0
existing_query + (options[:query].is_a?(Hash) ? default_params.merge(options[:query]).to_query : options[:query])
0
klass = Net::HTTP.const_get method.to_s.downcase.capitalize
0
request = klass.new(uri.request_uri)
0
request.body = options[:body].is_a?(Hash) ? options[:body].to_query : options[:body] unless options[:body].blank?
0
basic_auth = options.delete(:basic_auth) || @auth
0
request.initialize_http_header headers.merge(options[:headers] || {})
0
- # note to self: self, do not put basic auth above headers because it removes basic auth
0
request.basic_auth(basic_auth[:username], basic_auth[:password]) if basic_auth
0
response = http(uri).request(request)
0
@format ||= format_from_mimetype(response['content-type'])