Constructs and sends a :class:`Request `. Returns :class:`Response ` object. :param method: method for the new :class:`Request` object. :param url: URL for the new :class:`Request` object. :param params: (optional) Dictionary or bytes to be sent in the query strin
(method, url, **kwargs)
| 15 | |
| 16 | |
| 17 | def request(method, url, **kwargs): |
| 18 | """Constructs and sends a :class:`Request <Request>`. |
| 19 | Returns :class:`Response <Response>` object. |
| 20 | |
| 21 | :param method: method for the new :class:`Request` object. |
| 22 | :param url: URL for the new :class:`Request` object. |
| 23 | :param params: (optional) Dictionary or bytes to be sent in the query string for the :class:`Request`. |
| 24 | :param data: (optional) Dictionary, bytes, or file-like object to send in the body of the :class:`Request`. |
| 25 | :param headers: (optional) Dictionary of HTTP Headers to send with the :class:`Request`. |
| 26 | :param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`. |
| 27 | :param files: (optional) Dictionary of 'name': file-like-objects (or {'name': ('filename', fileobj)}) for multipart encoding upload. |
| 28 | :param auth: (optional) Auth tuple to enable Basic/Digest/Custom HTTP Auth. |
| 29 | :param timeout: (optional) Float describing the timeout of the request. |
| 30 | :param allow_redirects: (optional) Boolean. Set to True if POST/PUT/DELETE redirect following is allowed. |
| 31 | :param proxies: (optional) Dictionary mapping protocol to the URL of the proxy. |
| 32 | :param verify: (optional) if ``True``, the SSL cert will be verified. A CA_BUNDLE path can also be provided. |
| 33 | :param stream: (optional) if ``False``, the response content will be immediately downloaded. |
| 34 | :param cert: (optional) if String, path to ssl client cert file (.pem). If Tuple, ('cert', 'key') pair. |
| 35 | |
| 36 | Usage:: |
| 37 | |
| 38 | >>> import requests |
| 39 | >>> req = requests.request('GET', 'http://httpbin.org/get') |
| 40 | <Response [200]> |
| 41 | """ |
| 42 | |
| 43 | session = sessions.Session() |
| 44 | return session.request(method=method, url=url, **kwargs) |
| 45 | |
| 46 | |
| 47 | def get(url, **kwargs): |