Compare commits

...

5 Commits

Author SHA1 Message Date
Kenneth Reitz
a8695ecd32 v0.6.2 2011-10-09 07:11:48 -04:00
Kenneth Reitz
98c719f714 Merge branch 'redirect-no-follow' of https://github.com/millerdev/requests 2011-10-09 07:05:14 -04:00
Daniel Miller
dda533cf67 Added myself to AUTHORS file 2011-10-05 15:09:57 -04:00
Daniel Miller
aa04cc9b42 Make get and head requests respect allow_redirects=False. 2011-10-05 14:36:12 -04:00
Kenneth Reitz
3b085ed20f Merge branch 'develop' 2011-08-20 18:26:04 -04:00
6 changed files with 32 additions and 6 deletions

View File

@@ -38,4 +38,5 @@ Patches and Suggestions
- Armin Ronacher
- Shrikant Sharat Kandula
- Mikko Ohtamaa
- Den Shabalin
- Den Shabalin
- Daniel Miller <danielm@vs-networks.com>

View File

@@ -1,6 +1,11 @@
History
-------
0.6.2 (2011-10-09)
++++++++++++++++++
* GET/HEAD obeys follow_redirect=False
0.6.1 (2011-08-20)
++++++++++++++++++

View File

@@ -90,9 +90,11 @@ def get(url, **kwargs):
:param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`.
:param auth: (optional) AuthObject to enable Basic HTTP Auth.
:param timeout: (optional) Float describing the timeout of the request.
:param allow_redirects: (optional) Boolean. Set to False to disable redirect following.
:param proxies: (optional) Dictionary mapping protocol to the URL of the proxy.
"""
kwargs.setdefault('allow_redirects', True)
return request('GET', url, **kwargs)
@@ -106,9 +108,11 @@ def head(url, **kwargs):
:param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`.
:param auth: (optional) AuthObject to enable Basic HTTP Auth.
:param timeout: (optional) Float describing the timeout of the request.
:param allow_redirects: (optional) Boolean. Set to False to disable redirect following.
:param proxies: (optional) Dictionary mapping protocol to the URL of the proxy.
"""
kwargs.setdefault('allow_redirects', True)
return request('HEAD', url, **kwargs)

View File

@@ -12,8 +12,8 @@ This module implements the main Requests system.
"""
__title__ = 'requests'
__version__ = '0.6.1'
__build__ = 0x000601
__version__ = '0.6.2'
__build__ = 0x000602
__author__ = 'Kenneth Reitz'
__license__ = 'ISC'
__copyright__ = 'Copyright 2011 Kenneth Reitz'

View File

@@ -203,9 +203,7 @@ class Request(object):
while (
('location' in r.headers) and
((self.method in ('GET', 'HEAD')) or
(r.status_code is codes.see_other) or
(self.allow_redirects))
((r.status_code is codes.see_other) or (self.allow_redirects))
):
r.close()

View File

@@ -422,6 +422,24 @@ class RequestsTestSuite(unittest.TestCase):
self.assertEquals(rbody.get('data'), '')
def test_GET_no_redirect(self):
for service in SERVICES:
r = requests.get(service('redirect', '3'), allow_redirects=False)
self.assertEquals(r.status_code, 302)
self.assertEquals(len(r.history), 0)
def test_HEAD_no_redirect(self):
for service in SERVICES:
r = requests.head(service('redirect', '3'), allow_redirects=False)
self.assertEquals(r.status_code, 302)
self.assertEquals(len(r.history), 0)
def test_redirect_history(self):
for service in SERVICES: