From dd6ecfb821059ee4f8ce79b7e2c3787deab4f2c3 Mon Sep 17 00:00:00 2001 From: James Billingham Date: Wed, 8 Jul 2015 14:33:06 +0100 Subject: [PATCH] Always maintain method for 307 & 308 responses Resolves #418 --- lib/httparty/request.rb | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/httparty/request.rb b/lib/httparty/request.rb index 45dbb3c..296aa63 100644 --- a/lib/httparty/request.rb +++ b/lib/httparty/request.rb @@ -276,7 +276,7 @@ module HTTParty unless options[:maintain_method_across_redirects] && options[:resend_on_redirect] self.http_method = Net::HTTP::Get end - else + elsif last_response.code != 307 && last_response.code != 308 unless options[:maintain_method_across_redirects] self.http_method = Net::HTTP::Get end @@ -305,12 +305,9 @@ module HTTParty def response_redirects? case last_response - when Net::HTTPMultipleChoice, # 300 - Net::HTTPMovedPermanently, # 301 - Net::HTTPFound, # 302 - Net::HTTPSeeOther, # 303 - Net::HTTPUseProxy, # 305 - Net::HTTPTemporaryRedirect + when Net::HTTPNotModified # 304 + false + when Net::HTTPRedirection options[:follow_redirects] && last_response.key?('location') end end