From d05dab88557cf2a198de8bf2de89eb6f51509534 Mon Sep 17 00:00:00 2001 From: Florian Munz Date: Tue, 23 Dec 2008 01:37:19 +0800 Subject: [PATCH] uri is an instance variable, no need to have it as an method argument Signed-off-by: John Nunemaker --- lib/httparty/request.rb | 6 +++--- spec/httparty/request_spec.rb | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/httparty/request.rb b/lib/httparty/request.rb index f524263..830e4c9 100644 --- a/lib/httparty/request.rb +++ b/lib/httparty/request.rb @@ -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] diff --git a/spec/httparty/request_spec.rb b/spec/httparty/request_spec.rb index 70fd967..92d53e0 100644 --- a/spec/httparty/request_spec.rb +++ b/spec/httparty/request_spec.rb @@ -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[1234Foo Bar!] + @request.send(:parse_response, xml) end end