mirror of
https://github.com/jnunemaker/httparty
synced 2023-03-27 23:23:07 -04:00
uri is an instance variable, no need to have it as an method argument
Signed-off-by: John Nunemaker <nunemaker@gmail.com>
This commit is contained in:
parent
790764ed74
commit
d05dab8855
2 changed files with 15 additions and 5 deletions
|
@ -31,18 +31,18 @@ module HTTParty
|
|||
|
||||
def perform
|
||||
validate!
|
||||
handle_response!(get_response(uri))
|
||||
handle_response!(get_response)
|
||||
end
|
||||
|
||||
private
|
||||
def http(uri) #:nodoc:
|
||||
def http #:nodoc:
|
||||
http = Net::HTTP.new(uri.host, uri.port, options[:http_proxyaddr], options[:http_proxyport])
|
||||
http.use_ssl = (uri.port == 443)
|
||||
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
||||
http
|
||||
end
|
||||
|
||||
def get_response(uri) #:nodoc:
|
||||
def get_response #:nodoc:
|
||||
request = http_method.new(uri.request_uri)
|
||||
|
||||
if post? && options[:query]
|
||||
|
|
|
@ -13,11 +13,21 @@ describe HTTParty::Request do
|
|||
|
||||
describe 'http' do
|
||||
it "should use ssl for port 443" do
|
||||
@request.send(:http, URI.parse('https://api.foo.com/v1:443')).use_ssl?.should == true
|
||||
request = HTTParty::Request.new(Net::HTTP::Get, 'https://api.foo.com/v1:443')
|
||||
request.send(:http).use_ssl?.should == true
|
||||
end
|
||||
|
||||
it 'should not use ssl for port 80' do
|
||||
@request.send(:http, URI.parse('http://foobar.com')).use_ssl?.should == false
|
||||
request = HTTParty::Request.new(Net::HTTP::Get, 'http://foobar.com')
|
||||
@request.send(:http).use_ssl?.should == false
|
||||
end
|
||||
end
|
||||
|
||||
describe 'http basic auth' do
|
||||
it "should use basic auth" do
|
||||
@request.options[:basic_auth] = {:username => 'foobar', :password => 'secret'}
|
||||
xml = %q[<books><book><id>1234</id><name>Foo Bar!</name></book></books>]
|
||||
@request.send(:parse_response, xml)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue