Sends an HTTP request. **Parameters:** * **method** - HTTP method for the new `Request` object: `GET`, `OPTIONS`, `HEAD`, `POST`, `PUT`, `PATCH`, or `DELETE`. * **url** - URL for the new `Request` object. * **params** - *(optional)* Query parameters to include in the URL,
(
method: str,
url: URL | str,
*,
params: QueryParamTypes | None = None,
content: RequestContent | None = None,
data: RequestData | None = None,
files: RequestFiles | None = None,
json: typing.Any | None = None,
headers: HeaderTypes | None = None,
cookies: CookieTypes | None = None,
auth: AuthTypes | None = None,
proxy: ProxyTypes | None = None,
timeout: TimeoutTypes = DEFAULT_TIMEOUT_CONFIG,
follow_redirects: bool = False,
verify: ssl.SSLContext | str | bool = True,
trust_env: bool = True,
)
| 37 | |
| 38 | |
| 39 | def request( |
| 40 | method: str, |
| 41 | url: URL | str, |
| 42 | *, |
| 43 | params: QueryParamTypes | None = None, |
| 44 | content: RequestContent | None = None, |
| 45 | data: RequestData | None = None, |
| 46 | files: RequestFiles | None = None, |
| 47 | json: typing.Any | None = None, |
| 48 | headers: HeaderTypes | None = None, |
| 49 | cookies: CookieTypes | None = None, |
| 50 | auth: AuthTypes | None = None, |
| 51 | proxy: ProxyTypes | None = None, |
| 52 | timeout: TimeoutTypes = DEFAULT_TIMEOUT_CONFIG, |
| 53 | follow_redirects: bool = False, |
| 54 | verify: ssl.SSLContext | str | bool = True, |
| 55 | trust_env: bool = True, |
| 56 | ) -> Response: |
| 57 | """ |
| 58 | Sends an HTTP request. |
| 59 | |
| 60 | **Parameters:** |
| 61 | |
| 62 | * **method** - HTTP method for the new `Request` object: `GET`, `OPTIONS`, |
| 63 | `HEAD`, `POST`, `PUT`, `PATCH`, or `DELETE`. |
| 64 | * **url** - URL for the new `Request` object. |
| 65 | * **params** - *(optional)* Query parameters to include in the URL, as a |
| 66 | string, dictionary, or sequence of two-tuples. |
| 67 | * **content** - *(optional)* Binary content to include in the body of the |
| 68 | request, as bytes or a byte iterator. |
| 69 | * **data** - *(optional)* Form data to include in the body of the request, |
| 70 | as a dictionary. |
| 71 | * **files** - *(optional)* A dictionary of upload files to include in the |
| 72 | body of the request. |
| 73 | * **json** - *(optional)* A JSON serializable object to include in the body |
| 74 | of the request. |
| 75 | * **headers** - *(optional)* Dictionary of HTTP headers to include in the |
| 76 | request. |
| 77 | * **cookies** - *(optional)* Dictionary of Cookie items to include in the |
| 78 | request. |
| 79 | * **auth** - *(optional)* An authentication class to use when sending the |
| 80 | request. |
| 81 | * **proxy** - *(optional)* A proxy URL where all the traffic should be routed. |
| 82 | * **timeout** - *(optional)* The timeout configuration to use when sending |
| 83 | the request. |
| 84 | * **follow_redirects** - *(optional)* Enables or disables HTTP redirects. |
| 85 | * **verify** - *(optional)* Either `True` to use an SSL context with the |
| 86 | default CA bundle, `False` to disable verification, or an instance of |
| 87 | `ssl.SSLContext` to use a custom context. |
| 88 | * **trust_env** - *(optional)* Enables or disables usage of environment |
| 89 | variables for configuration. |
| 90 | |
| 91 | **Returns:** `Response` |
| 92 | |
| 93 | Usage: |
| 94 | |
| 95 | ``` |
| 96 | >>> import httpx |