: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)
: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)
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()
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: