Permalink
Browse files

Revert "ensure only GET and HEAD requests follow redirects"

This reverts commit 71602a5.

ref #281
  • Loading branch information...
1 parent cc09d92 commit e1e02096f2e3719d4f6f3735a58f38b375bf186d @leejarvis leejarvis committed Mar 5, 2013
Showing with 7 additions and 14 deletions.
  1. +1 −5 lib/mechanize/http/agent.rb
  2. +6 −9 test/test_mechanize.rb
@@ -301,11 +301,7 @@ def fetch uri, method = :get, headers = {}, params = [],
log.debug("Got cached page") if log
visited_page(uri) || page
when Net::HTTPRedirection
- if request.is_a?(Net::HTTP::Head) or request.is_a?(Net::HTTP::Get)
- response_redirect response, method, page, redirects, headers, referer
- else
- page
- end
+ response_redirect response, method, page, redirects, headers, referer
when Net::HTTPUnauthorized
response_authenticate(response, page, uri, request, headers, params,
referer)
View
@@ -292,10 +292,9 @@ def test_delete
def test_delete_redirect
page = @mech.delete('http://localhost/redirect')
- assert_equal(page.uri.to_s, 'http://localhost/redirect')
+ assert_equal(page.uri.to_s, 'http://localhost/verb')
- assert_equal '302', page.code
- assert_equal '/verb', page.header['Location']
+ assert_equal 'GET', page.header['X-Request-Method']
end
def test_download
@@ -948,10 +947,9 @@ def test_post_multipart
def test_post_redirect
page = @mech.post('http://localhost/redirect')
- assert_equal(page.uri.to_s, 'http://localhost/redirect')
+ assert_equal(page.uri.to_s, 'http://localhost/verb')
- assert_equal '302', page.code
- assert_equal '/verb', page.header['Location']
+ assert_equal 'GET', page.header['X-Request-Method']
end
def test_put
@@ -963,10 +961,9 @@ def test_put
def test_put_redirect
page = @mech.put('http://localhost/redirect', 'foo')
- assert_equal(page.uri.to_s, 'http://localhost/redirect')
+ assert_equal(page.uri.to_s, 'http://localhost/verb')
- assert_equal '302', page.code
- assert_equal '/verb', page.header['Location']
+ assert_equal 'GET', page.header['X-Request-Method']
end
def test_read_timeout_equals

0 comments on commit e1e0209

Please sign in to comment.