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

Method _send_single_request

httpx/_client.py:1001–1034  ·  view source on GitHub ↗

Sends a single request, without handling any redirections.

(self, request: Request)

Source from the content-addressed store, hash-verified

999 raise exc
1000
1001 def _send_single_request(self, request: Request) -> Response:
1002 """
1003 Sends a single request, without handling any redirections.
1004 """
1005 transport = self._transport_for_url(request.url)
1006 start = time.perf_counter()
1007
1008 if not isinstance(request.stream, SyncByteStream):
1009 raise RuntimeError(
1010 "Attempted to send an async request with a sync Client instance."
1011 )
1012
1013 with request_context(request=request):
1014 response = transport.handle_request(request)
1015
1016 assert isinstance(response.stream, SyncByteStream)
1017
1018 response.request = request
1019 response.stream = BoundSyncStream(
1020 response.stream, response=response, start=start
1021 )
1022 self.cookies.extract_cookies(response)
1023 response.default_encoding = self._default_encoding
1024
1025 logger.info(
1026 'HTTP Request: %s %s "%s %d %s"',
1027 request.method,
1028 request.url,
1029 response.http_version,
1030 response.status_code,
1031 response.reason_phrase,
1032 )
1033
1034 return response
1035
1036 def get(
1037 self,

Callers 1

Calls 6

_transport_for_urlMethod · 0.95
request_contextFunction · 0.85
BoundSyncStreamClass · 0.85
extract_cookiesMethod · 0.80
infoMethod · 0.80
handle_requestMethod · 0.45

Tested by

no test coverage detected