mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 22:50:18 +00:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -117,3 +117,4 @@ Patches and Suggestions
|
||||
- Stephen Zhuang (everbird)
|
||||
- Martijn Pieters
|
||||
- Jonatan Heyman
|
||||
- David Bonner <dbonner@gmail.com> @rascalking
|
||||
|
||||
@@ -94,16 +94,13 @@ class SessionRedirectMixin(object):
|
||||
url = urljoin(resp.url, requote_uri(url))
|
||||
|
||||
# http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.4
|
||||
if resp.status_code is codes.see_other:
|
||||
if resp.status_code is codes.see_other and req.method != 'HEAD':
|
||||
method = 'GET'
|
||||
|
||||
# Do what the browsers do, despite standards...
|
||||
if resp.status_code in (codes.moved, codes.found) and req.method == 'POST':
|
||||
method = 'GET'
|
||||
|
||||
if (resp.status_code == 303) and req.method != 'HEAD':
|
||||
method = 'GET'
|
||||
|
||||
# Remove the cookie headers that were sent.
|
||||
headers = req.headers
|
||||
try:
|
||||
@@ -255,7 +252,7 @@ class Session(SessionRedirectMixin):
|
||||
|
||||
# Create the Request.
|
||||
req = Request()
|
||||
req.method = method
|
||||
req.method = method.upper()
|
||||
req.url = url
|
||||
req.headers = headers
|
||||
req.files = files
|
||||
|
||||
@@ -86,6 +86,10 @@ class RequestsTestCase(unittest.TestCase):
|
||||
r = requests.get(httpbin('redirect', '1'))
|
||||
self.assertEqual(r.status_code, 200)
|
||||
|
||||
def test_HTTP_302_ALLOW_REDIRECT_POST(self):
|
||||
r = requests.post(httpbin('status', '302'), data={'some': 'data'})
|
||||
self.assertEqual(r.status_code, 200)
|
||||
|
||||
def test_HTTP_200_OK_GET_WITH_PARAMS(self):
|
||||
heads = {'User-agent': 'Mozilla/5.0'}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user