telegram.utils.request.Request¶
-
class
telegram.utils.request.Request(con_pool_size=1, proxy_url=None, urllib3_proxy_kwargs=None, connect_timeout=5.0, read_timeout=5.0)¶ Bases:
objectHelper class for python-telegram-bot which provides methods to perform POST & GET towards telegram servers.
- Parameters
con_pool_size (int) – Number of connections to keep in the connection pool.
proxy_url (str) – The URL to the proxy server. For example: http://127.0.0.1:3128.
urllib3_proxy_kwargs (dict) – Arbitrary arguments passed as-is to urllib3.ProxyManager. This value will be ignored if proxy_url is not set.
connect_timeout (int|float) – The maximum amount of time (in seconds) to wait for a connection attempt to a server to succeed. None will set an infinite timeout for connection attempts. (default: 5.)
read_timeout (int|float) – The maximum amount of time (in seconds) to wait between consecutive read operations for a response from the server. None will set an infinite timeout. This value is usually overridden by the various
telegram.Botmethods. (default: 5.)
-
property
con_pool_size¶ The size of the connection pool used.
-
download(url, filename, timeout=None)¶ Download a file by its URL.
- Parameters
url (str) – The web location we want to retrieve.
timeout (
int|float) – If this value is specified, use it as the read timeout from the server (instead of the one specified during creation of the connection pool).filename (
str) – The filename within the path to download the file.
- Return type
None
-
post(url, data, timeout=None)¶ Request an URL.
- Parameters
url (
str) – The web location we want to retrieve.data (dict[str, str|int], optional) – A dict of key/value pairs.
timeout (
int|float, optional) – If this value is specified, use it as the read timeout from the server (instead of the one specified during creation of the connection pool).
- Returns
A JSON object.
- Return type
Union[Dict[str, Any], bool]
-
retrieve(url, timeout=None)¶ Retrieve the contents of a file by its URL.
- Parameters
url (
str) – The web location we want to retrieve.timeout (
int|float) – If this value is specified, use it as the read timeout from the server (instead of the one specified during creation of the connection pool).
- Return type
bytes