MCPcopy
hub / github.com/encode/httpx / send

Method send

httpx/_client.py:879–928  ·  httpx/_client.py::Client.send

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,
    )

Source from the content-addressed store, hash-verified

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,

Callers 15

requestMethod · 0.95
streamMethod · 0.95
test_next_requestFunction · 0.95
sync_auth_flowMethod · 0.45
async_auth_flowMethod · 0.45
_send_handling_authMethod · 0.45
test_basic_authFunction · 0.45

Calls 5

_send_handling_authMethod · 0.95
_set_timeoutMethod · 0.80
_build_request_authMethod · 0.80
readMethod · 0.45
closeMethod · 0.45