Send a request. The request is sent as-is, unmodified. Typically you'll want to build one with `Client.build_request()` so that any client-level configuration is merged into the request, but passing an explicit `httpx.Request()` is supported as well.
(
self,
request: Request,
*,
stream: bool = False,
auth: AuthTypes | UseClientDefault | None = USE_CLIENT_DEFAULT,
follow_redirects: bool | UseClientDefault = USE_CLIENT_DEFAULT,
)
| 877 | response.close() |
| 878 | |
| 879 | def send( |
| 880 | self, |
| 881 | request: Request, |
| 882 | *, |
| 883 | stream: bool = False, |
| 884 | auth: AuthTypes | UseClientDefault | None = USE_CLIENT_DEFAULT, |
| 885 | follow_redirects: bool | UseClientDefault = USE_CLIENT_DEFAULT, |
| 886 | ) -> Response: |
| 887 | class="st">""" |
| 888 | Send a request. |
| 889 | |
| 890 | The request is sent as-is, unmodified. |
| 891 | |
| 892 | Typically you&class="cm">#x27;ll want to build one with `Client.build_request()` |
| 893 | so that any client-level configuration is merged into the request, |
| 894 | but passing an explicit `httpx.Request()` is supported as well. |
| 895 | |
| 896 | See also: [Request instances][0] |
| 897 | |
| 898 | [0]: /advanced/clients/class="cm">#request-instances |
| 899 | class="st">""" |
| 900 | if self._state == ClientState.CLOSED: |
| 901 | raise RuntimeError(class="st">"Cannot send a request, as the client has been closed.") |
| 902 | |
| 903 | self._state = ClientState.OPENED |
| 904 | follow_redirects = ( |
| 905 | self.follow_redirects |
| 906 | if isinstance(follow_redirects, UseClientDefault) |
| 907 | else follow_redirects |
| 908 | ) |
| 909 | |
| 910 | self._set_timeout(request) |
| 911 | |
| 912 | auth = self._build_request_auth(request, auth) |
| 913 | |
| 914 | response = self._send_handling_auth( |
| 915 | request, |
| 916 | auth=auth, |
| 917 | follow_redirects=follow_redirects, |
| 918 | history=[], |
| 919 | ) |
| 920 | try: |
| 921 | if not stream: |
| 922 | response.read() |
| 923 | |
| 924 | return response |
| 925 | |
| 926 | except BaseException as exc: |
| 927 | response.close() |
| 928 | raise exc |
| 929 | |
| 930 | def _send_handling_auth( |
| 931 | self, |