mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 22:50:18 +00:00
Conform api.* arguments to api.request arguments.
Fixes #40. Fixes #41.
This commit is contained in:
+16
-10
@@ -53,7 +53,7 @@ def request(method, url, params=None, data=None, headers=None, cookies=None, fil
|
||||
|
||||
return r.response
|
||||
|
||||
def get(url, params={}, headers={}, cookies=None, auth=None, **kwargs):
|
||||
def get(url, params=None, headers=None, cookies=None, auth=None, timeout=None):
|
||||
"""Sends a GET request. Returns :class:`Response` object.
|
||||
|
||||
:param url: URL for the new :class:`Request` object.
|
||||
@@ -64,10 +64,10 @@ def get(url, params={}, headers={}, cookies=None, auth=None, **kwargs):
|
||||
:param timeout: (optional) Float describing the timeout of the request.
|
||||
"""
|
||||
|
||||
return request('GET', url, params=params, headers=headers, cookies=cookies, auth=auth, **kwargs)
|
||||
return request('GET', url, params=params, headers=headers, cookies=cookies, auth=auth, timeout=timeout)
|
||||
|
||||
|
||||
def head(url, params={}, headers={}, cookies=None, auth=None, **kwargs):
|
||||
def head(url, params=None, headers=None, cookies=None, auth=None, timeout=None):
|
||||
"""Sends a HEAD request. Returns :class:`Response` object.
|
||||
|
||||
:param url: URL for the new :class:`Request` object.
|
||||
@@ -78,10 +78,10 @@ def head(url, params={}, headers={}, cookies=None, auth=None, **kwargs):
|
||||
:param timeout: (optional) Float describing the timeout of the request.
|
||||
"""
|
||||
|
||||
return request('HEAD', url, params=params, headers=headers, cookies=cookies, auth=auth, **kwargs)
|
||||
return request('HEAD', url, params=params, headers=headers, cookies=cookies, auth=auth, timeout=timeout)
|
||||
|
||||
|
||||
def post(url, data={}, headers={}, files=None, cookies=None, auth=None, **kwargs):
|
||||
def post(url, data=None, headers=None, files=None, cookies=None, auth=None, timeout=None, allow_redirects=False):
|
||||
"""Sends a POST request. Returns :class:`Response` object.
|
||||
|
||||
:param url: URL for the new :class:`Request` object.
|
||||
@@ -91,12 +91,14 @@ def post(url, data={}, headers={}, files=None, cookies=None, auth=None, **kwargs
|
||||
:param cookies: (optional) 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 True if redirect following is allowed.
|
||||
"""
|
||||
|
||||
return request('POST', url, data=data, headers=headers, files=files, cookies=cookies, auth=auth, **kwargs)
|
||||
return request('POST', url, data=data, headers=headers, files=files, cookies=cookies, auth=auth,
|
||||
timeout=timeout, allow_redirects=allow_redirects)
|
||||
|
||||
|
||||
def put(url, data='', headers={}, files={}, cookies=None, auth=None, **kwargs):
|
||||
def put(url, data=None, headers=None, files=None, cookies=None, auth=None, timeout=None, allow_redirects=False):
|
||||
"""Sends a PUT request. Returns :class:`Response` object.
|
||||
|
||||
:param url: URL for the new :class:`Request` object.
|
||||
@@ -106,12 +108,14 @@ def put(url, data='', headers={}, files={}, cookies=None, auth=None, **kwargs):
|
||||
:param cookies: (optional) 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 True if redirect following is allowed.
|
||||
"""
|
||||
|
||||
return request('PUT', url, data=data, headers=headers, files=files, cookies=cookies, auth=auth, **kwargs)
|
||||
return request('PUT', url, data=data, headers=headers, files=files, cookies=cookies, auth=auth,
|
||||
timeout=timeout, allow_redirects=allow_redirects)
|
||||
|
||||
|
||||
def delete(url, params={}, headers={}, cookies=None, auth=None, **kwargs):
|
||||
def delete(url, params=None, headers=None, cookies=None, auth=None, timeout=None, allow_redirects=False):
|
||||
"""Sends a DELETE request. Returns :class:`Response` object.
|
||||
|
||||
:param url: URL for the new :class:`Request` object.
|
||||
@@ -120,6 +124,8 @@ def delete(url, params={}, headers={}, cookies=None, auth=None, **kwargs):
|
||||
:param cookies: (optional) 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 True if redirect following is allowed.
|
||||
"""
|
||||
|
||||
return request('DELETE', url, params=params, headers=headers, cookies=cookies, auth=auth, **kwargs)
|
||||
return request('DELETE', url, params=params, headers=headers, cookies=cookies, auth=auth,
|
||||
timeout=timeout, allow_redirects=allow_redirects)
|
||||
|
||||
Reference in New Issue
Block a user