Cette partie de la documentation présente toutes les interfaces possibles de Requests. Pour certaines parties, Requests dépend de librairies externes, nous documentons les plus importantes ici et fournissons des liens vers les documentations externes.
Toutes les fonctionnalités de Requests sont accessibles via ces 7 méthodes. Elles retournent toutes une instance de l’objet Response.
The core Response object. All Request objects contain a response attribute, which is an instance of this class.
Dictionary of configurations for this request.
Content of the response, in bytes.
A CookieJar of Cookies the server sent back.
Encoding to decode with when accessing r.text.
Case-insensitive Dictionary of Response Headers. For example, headers['content-encoding'] will return the value of a 'Content-Encoding' response header.
A list of Response objects from the history of the Request. Any redirect responses will end up here. The list is sorted from the oldest to the most recent request.
Iterates over the response data. This avoids reading the content at once into memory for large responses. The chunk size is the number of bytes it should read into memory. This is not necessarily the length of each item returned as decoding can take place.
Iterates over the response data, one line at a time. This avoids reading the content at once into memory for large responses.
Returns the json-encoded content of a response, if any.
Returns the parsed header links of the response, if any.
File-like object representation of response (for advanced usage).
The HTTP Reason for the response.
Integer Code of responded HTTP Status.
Content of the response, in unicode.
if Response.encoding is None and chardet module is available, encoding will be guessed.
Final URL location of Response.
Sends a HEAD request. Returns Response object.
Parameters: |
|
---|
Sends a GET request. Returns Response object.
Parameters: |
|
---|
Sends a PATCH request. Returns Response object.
Parameters: |
---|
Sends a DELETE request. Returns Response object.
Parameters: |
|
---|
There was an ambiguous exception that occurred while handling your request.
A Connection error occurred.
An HTTP error occurred.
A valid URL is required to make a request.
Too many redirects.
This module provides the Requests configuration defaults.
Configurations:
base_headers: | Default HTTP headers. |
---|---|
verbose: | Stream to write request logging to. |
max_redirects: | Maximum number of redirects allowed within a request.s |
keep_alive: | Reuse HTTP Connections? |
max_retries: | The number of times a request should be retried in the event of a connection failure. |
danger_mode: | If true, Requests will raise errors immediately. |
safe_mode: | If true, Requests will catch all errors. |
strict_mode: | If true, Requests will do its best to follow RFCs (e.g. POST redirects). |
pool_maxsize: | The maximium size of an HTTP connection pool. |
pool_connections: | |
The number of active HTTP connection pools to use. | |
encode_uri: | If true, URIs will automatically be percent-encoded. |
trust_env: | If true, the surrouding environment will be trusted (environ, netrc). |
param store_cookies: | |
If false, the received cookies as part of the HTTP response would be ignored. |
Ces fonctions sont utilisées en internes, mais peuvent être utiles en dehors de Requests.
Dictionary lookup object.
>>> requests.codes['temporary_redirect']
307
>>> requests.codes.teapot
418
>>> requests.codes['\o/']
200
Returns a key/value dictionary from a CookieJar.
Parameters: | cj – CookieJar object to extract cookies from. |
---|
Returns a CookieJar from a key/value dictionary.
Parameters: | cookie_dict – Dict of key/values to insert into CookieJar. |
---|
Returns a CookieJar from a key/value dictionary.
Parameters: |
|
---|
Returns encodings from given content string.
Parameters: | content – bytestring to extract encodings from. |
---|
Returns encodings from given HTTP Header Dict.
Parameters: | headers – dictionary to extract encoding from. |
---|
Returns the requested content back in unicode.
Parameters: | r – Response object to get unicode content from. |
---|
Tried:
Ces éléments sont des composants internes de Requests, et ne doivent jamais être vus par l’utilisateur final (développeur). Cette partie de la documentation existe uniquement pour ceux qui étendent les fonctionnalités de Requests.
The core Response object. All Request objects contain a response attribute, which is an instance of this class.
Dictionary of configurations for this request.
Content of the response, in bytes.
A CookieJar of Cookies the server sent back.
Encoding to decode with when accessing r.text.
Resulting HTTPError of request, if one occurred.
Case-insensitive Dictionary of Response Headers. For example, headers['content-encoding'] will return the value of a 'Content-Encoding' response header.
A list of Response objects from the history of the Request. Any redirect responses will end up here. The list is sorted from the oldest to the most recent request.
Iterates over the response data. This avoids reading the content at once into memory for large responses. The chunk size is the number of bytes it should read into memory. This is not necessarily the length of each item returned as decoding can take place.
Iterates over the response data, one line at a time. This avoids reading the content at once into memory for large responses.
Returns the json-encoded content of a response, if any.
Returns the parsed header links of the response, if any.
Raises stored HTTPError or URLError, if one occurred.
File-like object representation of response (for advanced usage).
The HTTP Reason for the response.
The Request that created the Response.
Integer Code of responded HTTP Status.
Content of the response, in unicode.
if Response.encoding is None and chardet module is available, encoding will be guessed.
Final URL location of Response.
The Request object. It carries out all functionality of Requests. Recommended interface is with the Requests functions.
Set to True if full redirects are allowed (e.g. re-POST-ing of data at new Location)
Authentication tuple or object to attach to Request.
SSL Certificate
Dictionary of configurations for this request.
Dictionary, bytes or file stream of request body data to attach to the Request.
Deregister a previously registered hook. Returns True if the hook existed, False if not.
Dictionary of files to multipart upload ({filename: content}).
Build the actual URL to use.
Dictionary of HTTP Headers to attach to the Request.
Event-handling hooks.
HTTP Method to use.
Dictionary or byte of querystring data to attach to the Request. The dictionary values can be lists for representing multivalued query parameters.
Build the path URL to use.
Prefetch response content
True if Request is part of a redirect chain (disables history and HTTPError storage).
Properly register a hook.
Response instance, containing content and metadata of HTTP Response, once sent.
Sends the request. Returns True if successful, False if not. If there was an HTTPError during transmission, self.response.status_code will contain the HTTPError code.
Once a request is successfully sent, sent will equal True.
Parameters: | anyway – If True, request will be sent, even if it has |
---|
already been sent.
Parameters: | prefetch – If not None, will override the request’s own setting |
---|
for prefetch.
True if Request has been sent.
Session.
Float describes the timeout of the request.
SSL Verification.
A Requests session.
Dispose of any internal state.
Currently, this just closes the PoolManager, which closes pooled connections.
Sends a DELETE request. Returns Response object.
Parameters: |
|
---|
Sends a GET request. Returns Response object.
Parameters: |
|
---|
Sends a HEAD request. Returns Response object.
Parameters: |
|
---|
Sends a OPTIONS request. Returns Response object.
Parameters: |
|
---|
Sends a PATCH request. Returns Response object.
Parameters: |
|
---|
Sends a POST request. Returns Response object.
Parameters: |
|
---|
Sends a PUT request. Returns Response object.
Parameters: |
|
---|
Constructs and sends a Request. Returns Response object.
Parameters: |
|
---|