MCPcopy
hub / github.com/scrapy/scrapy / _make_request

Method _make_request

scrapy/core/downloader/handlers/_httpx.py:113–145  ·  view source on GitHub ↗
(
        self, request: Request, timeout: float
    )

Source from the content-addressed store, hash-verified

111
112 @asynccontextmanager
113 async def _make_request(
114 self, request: Request, timeout: float
115 ) -> AsyncIterator[httpx.Response]:
116 client = self._get_client(self._extract_proxy_url_with_creds(request))
117 try:
118 async with client.stream(
119 request.method,
120 request.url,
121 content=request.body,
122 headers=request.headers.to_tuple_list(),
123 timeout=timeout,
124 ) as response:
125 yield response
126 except httpx.TimeoutException as e:
127 raise DownloadTimeoutError(
128 f"Getting {request.url} took longer than {timeout} seconds."
129 ) from e
130 except httpx.UnsupportedProtocol as e:
131 raise UnsupportedURLSchemeError(str(e)) from e
132 except httpx.ConnectError as e:
133 error_message = str(e)
134 if (
135 "Name or service not known" in error_message
136 or "getaddrinfo failed" in error_message
137 or "nodename nor servname" in error_message
138 or "Temporary failure in name resolution" in error_message
139 ):
140 raise CannotResolveHostError(error_message) from e
141 raise DownloadConnectionRefusedError(str(e)) from e
142 except httpx.ProxyError as e:
143 raise DownloadConnectionRefusedError(str(e)) from e
144 except (httpx.NetworkError, httpx.RemoteProtocolError) as e:
145 raise DownloadFailedError(str(e)) from e
146
147 @staticmethod
148 def _extract_headers(response: httpx.Response) -> Headers:

Callers

nothing calls this directly

Calls 8

_get_clientMethod · 0.95
DownloadFailedErrorClass · 0.90
to_tuple_listMethod · 0.80

Tested by

no test coverage detected