1
0
Fork 0
mirror of https://github.com/jnunemaker/httparty synced 2023-03-27 23:23:07 -04:00
This commit is contained in:
Sandro Turriate 2011-01-18 15:09:19 -05:00
parent def1d461e8
commit e9f8739b63
2 changed files with 12 additions and 20 deletions

View file

@ -66,7 +66,8 @@ module HTTParty
def perform def perform
validate validate
setup_raw_request setup_raw_request
get_response self.last_response = http.request(@raw_request)
handle_deflation
handle_response handle_response
end end
@ -158,14 +159,6 @@ module HTTParty
end end
end end
def perform_actual_request
http.request(@raw_request)
end
def get_response
self.last_response = perform_actual_request
end
def query_string(uri) def query_string(uri)
query_string_parts = [] query_string_parts = []
query_string_parts << uri.query unless uri.query.nil? query_string_parts << uri.query unless uri.query.nil?
@ -183,7 +176,6 @@ module HTTParty
# Raises exception Net::XXX (http error code) if an http error occured # Raises exception Net::XXX (http error code) if an http error occured
def handle_response def handle_response
handle_deflation
case last_response case last_response
when Net::HTTPMultipleChoice, # 300 when Net::HTTPMultipleChoice, # 300
Net::HTTPMovedPermanently, # 301 Net::HTTPMovedPermanently, # 301

View file

@ -8,7 +8,7 @@ module HTTParty
response.stub!(:body).and_return(data) response.stub!(:body).and_return(data)
http_request = HTTParty::Request.new(Net::HTTP::Get, 'http://localhost', :format => format) http_request = HTTParty::Request.new(Net::HTTP::Get, 'http://localhost', :format => format)
http_request.stub!(:perform_actual_request).and_return(response) http_request.stub_chain(:http, :request).and_return(response)
HTTParty::Request.should_receive(:new).and_return(http_request) HTTParty::Request.should_receive(:new).and_return(http_request)
end end