Advertisement
Guest User

Untitled

a guest
Sep 29th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. """Constructs and sends a :class:`Request <Request>`.
  2.  
  3. :param method: method for the new :class:`Request` object.
  4. :param url: URL for the new :class:`Request` object.
  5. :param params: (optional) Dictionary or bytes to be sent in the query string for the :class:`Request`.
  6. :param data: (optional) Dictionary, bytes, or file-like object to send in the body of the :class:`Request`.
  7. :param json: (optional) json data to send in the body of the :class:`Request`.
  8. :param headers: (optional) Dictionary of HTTP Headers to send with the :class:`Request`.
  9. :param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`.
  10. :param files: (optional) Dictionary of ``'name': file-like-objects`` (or ``{'name': file-tuple}``) for multipart encoding upload.
  11. ``file-tuple`` can be a 2-tuple ``('filename', fileobj)``, 3-tuple ``('filename', fileobj, 'content_type')``
  12. or a 4-tuple ``('filename', fileobj, 'content_type', custom_headers)``, where ``'content-type'`` is a string
  13. defining the content type of the given file and ``custom_headers`` a dict-like object containing additional headers
  14. to add for the file.
  15. :param auth: (optional) Auth tuple to enable Basic/Digest/Custom HTTP Auth.
  16. :param timeout: (optional) How long to wait for the server to send data
  17. before giving up, as a float, or a :ref:`(connect timeout, read
  18. timeout) <timeouts>` tuple.
  19. :type timeout: float or tuple
  20. :param allow_redirects: (optional) Boolean. Set to True if POST/PUT/DELETE redirect following is allowed.
  21. :type allow_redirects: bool
  22. :param proxies: (optional) Dictionary mapping protocol to the URL of the proxy.
  23. :param verify: (optional) whether the SSL cert will be verified. A CA_BUNDLE path can also be provided. Defaults to ``True``.
  24. :param stream: (optional) if ``False``, the response content will be immediately downloaded.
  25. :param cert: (optional) if String, path to ssl client cert file (.pem). If Tuple, ('cert', 'key') pair.
  26. :return: :class:`Response <Response>` object
  27. :rtype: requests.Response
  28.  
  29. Usage::
  30.  
  31. >>> import requests
  32. >>> req = requests.request('GET', 'http://httpbin.org/get')
  33. <Response [200]>
  34. """
  35.  
  36. # By using the 'with' statement we are sure the session is closed, thus we
  37. # avoid leaving sockets open which can trigger a ResourceWarning in some
  38. # cases, and look like a memory leak in others.
  39. with sessions.Session() as session:
  40. return session.request(method=method, url=url, **kwargs)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement