Skip to content
Myr

Merge pull request #1064 from rascalking/master

Before adoption: this commit came in with the history the project adopted, so no landing records it.

fix POST redirects

authored by Kenneth Reitz · committed by Kenneth Reitz · parents aaa3bf1, 7d085b1 · Browse files · 3 files+7 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+7 added−5 removed

  • other:+7 added−5 removed

3 files+7 added−5 removed

modified:requests/sessions.py+2 added-5 removed
92 unmodified lines
93 # Compliant with RFC3986, we percent encode the url.94 url = urljoin(resp.url, requote_uri(url))9596 # http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.497 if resp.status_code is codes.see_other:97 if resp.status_code is codes.see_other and req.method != 'HEAD':98 method = 'GET'99100 # Do what the browsers do, despite standards...101 if resp.status_code in (codes.moved, codes.found) and req.method == 'POST':102 method = 'GET'103104 if (resp.status_code == 303) and req.method != 'HEAD':105 method = 'GET'106104 # Remove the cookie headers that were sent.105 headers = req.headers106 try:107 del headers['Cookie']
133 unmodified lines
241242243 # Create the Request.244 req = Request()248 req.method = method245 req.method = method.upper()246 req.url = url247 req.headers = headers248 req.files = files249 req.data = data
138 unmodified lines
modified:AUTHORS.rst+1 added
115 unmodified lines
116- André Graf (dergraf)117- Stephen Zhuang (everbird)118- Martijn Pieters119- Jonatan Heyman120- David Bonner <dbonner@gmail.com> @rascalking
modified:test_requests.py+4 added
84 unmodified lines
85 def test_HTTP_302_ALLOW_REDIRECT_GET(self):86 r = requests.get(httpbin('redirect', '1'))87 self.assertEqual(r.status_code, 200)8889 def test_HTTP_302_ALLOW_REDIRECT_POST(self):90 r = requests.post(httpbin('status', '302'), data={'some': 'data'})91 self.assertEqual(r.status_code, 200)9293 def test_HTTP_200_OK_GET_WITH_PARAMS(self):94 heads = {'User-agent': 'Mozilla/5.0'}9596 r = requests.get(httpbin('user-agent'), headers=heads)
165 unmodified lines