Added support for OPTIONS method.
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by jbrendel · committed by jbrendel · parent 8c90c61 · Browse files · 5 files·+29 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
5 files+29 added−5 removed
- other:+29 added−5 removed
Provenance
- Commit
73ba48b- Tree
bdc6dc6- Author
jbrendel <juergen@brendel.com>- Committer
jbrendel <juergen@brendel.com>- Parent
8c90c61
5 files changed+29 added−5 removed
modified:requests/__init__.py+1 added-1 removed
22 unmodified lines23 24 25 from . import utils26 from .models import Request, Response27-from .api import request, get, head, post, patch, put, delete27+from .api import request, get, options, head, post, patch, put, delete28 from .sessions import session29 from .status_codes import codes30 from .exceptions import (31 RequestException, AuthenticationError, Timeout, URLRequired,2 unmodified linesmodified:requests/api.py+12 added-1 removed
11 unmodified lines12 """13 14 from .sessions import session15 16-__all__ = ('request', 'get', 'head', 'post', 'patch', 'put', 'delete')16+__all__ = ('request', 'get', 'options', 'head', 'post', 'patch', 'put', 'delete')17 18 19 def request(method, url,20 params=None,45 unmodified lines66 kwargs.setdefault('allow_redirects', True)67 return request('GET', url, **kwargs)68 69 70+def options(url, **kwargs):71+ """Sends a OPTIONS request. Returns :class:`Response` object.72+73+ :param url: URL for the new :class:`Request` object.74+ :param **kwargs: Optional arguments that ``request`` takes.75+ """76+77+ kwargs.setdefault('allow_redirects', True)78+ return request('OPTIONS', url, **kwargs)79+80+81 def head(url, **kwargs):82 """Sends a HEAD request. Returns :class:`Response` object.83 84 :param url: URL for the new :class:`Request` object.48 unmodified linesmodified:requests/async.py+2 added-1 removed
22 unmodified lines23 24 25 __all__ = (26 'map',27- 'get', 'head', 'post', 'put', 'patch', 'delete', 'request'27+ 'get', 'options', 'head', 'post', 'put', 'patch', 'delete', 'request'28 )29 30 31 def patched(f):20 unmodified lines52 53 54 # Patched requests.api functions.55 get = patched(api.get)56+options = patched(api.options)57 head = patched(api.head)58 post = patched(api.post)59 put = patched(api.put)60 patch = patched(api.patch)22 unmodified linesmodified:requests/sessions.py+12 added-1 removed
186 unmodified lines187 kwargs.setdefault('allow_redirects', True)188 return self.request('GET', url, **kwargs)189 190 191+ def options(self, url, **kwargs):192+ """Sends a OPTIONS request. Returns :class:`Response` object.193+194+ :param url: URL for the new :class:`Request` object.195+ :param **kwargs: Optional arguments that ``request`` takes.196+ """197+198+ kwargs.setdefault('allow_redirects', True)199+ return self.request('OPTIONS', url, **kwargs)200+201+202 def head(self, url, **kwargs):203 """Sends a HEAD request. Returns :class:`Response` object.204 205 :param url: URL for the new :class:`Request` object.50 unmodified lines256 257 def session(**kwargs):258 """Returns a :class:`Session` for context-management."""259 249- return Session(**kwargs)260+ return Session(**kwargs)modified:AUTHORS+2 added-1 removed
47 unmodified lines48 - Fredrik Möllerstrand49 - Daniel Hengeveld50 - Dan Head51 - Bruno Renié52-- David Fischer52+- David Fischer53+- Juergen Brendel