From: Kenneth Reitz Date: Sat, 22 Oct 2011 22:15:28 +0000 (-0400) Subject: Add all methods to session X-Git-Tag: v0.7.0~14^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2b3bd78685f9d30bf29e090b58f5aa1a3b799cdf;p=services%2Fpython-requests.git Add all methods to session --- diff --git a/requests/sessions.py b/requests/sessions.py index 0dc5e9d..1d130a3 100644 --- a/requests/sessions.py +++ b/requests/sessions.py @@ -167,6 +167,7 @@ class Session(object): return r.response + def get(self, url, **kwargs): """Sends a GET request. Returns :class:`Response` object. @@ -178,6 +179,61 @@ class Session(object): return self.request('GET', url, **kwargs) + def head(self, url, **kwargs): + """Sends a HEAD request. Returns :class:`Response` object. + + :param url: URL for the new :class:`Request` object. + :param **kwargs: Optional arguments that ``request`` takes. + """ + + kwargs.setdefault('allow_redirects', True) + return self.request('HEAD', url, **kwargs) + + + def post(self, url, data='', **kwargs): + """Sends a POST request. Returns :class:`Response` object. + + :param url: URL for the new :class:`Request` object. + :param data: (optional) Dictionary or bytes to send in the body of the :class:`Request`. + :param **kwargs: Optional arguments that ``request`` takes. + """ + + return self.request('post', url, data=data, **kwargs) + + + def put(self, url, data='', **kwargs): + """Sends a PUT request. Returns :class:`Response` object. + + :param url: URL for the new :class:`Request` object. + :param data: (optional) Dictionary or bytes to send in the body of the :class:`Request`. + :param **kwargs: Optional arguments that ``request`` takes. + """ + + return self.request('put', url, data=data, **kwargs) + + + def patch(url, data='', **kwargs): + """Sends a PATCH request. Returns :class:`Response` object. + + :param url: URL for the new :class:`Request` object. + :param data: (optional) Dictionary or bytes to send in the body of the :class:`Request`. + :param **kwargs: Optional arguments that ``request`` takes. + """ + + return self.request('patch', url, data='', **kwargs) + + + def delete(self, url, **kwargs): + """Sends a DELETE request. Returns :class:`Response` object. + + :param url: URL for the new :class:`Request` object. + :param **kwargs: Optional arguments that ``request`` takes. + """ + + return self.request('delete', url, **kwargs) + + + def session(**kwargs): """Returns a :class:`Session` for context-management."""