(
self,
url: str,
*,
method: HttpMethod = 'GET',
headers: HttpHeaders | dict[str, str] | None = None,
payload: HttpPayload | None = None,
session: Session | None = None,
proxy_info: ProxyInfo | None = None,
timeout: timedelta | None = None,
)
| 191 | @asynccontextmanager |
| 192 | @override |
| 193 | async def stream( |
| 194 | self, |
| 195 | url: str, |
| 196 | *, |
| 197 | method: HttpMethod = 'GET', |
| 198 | headers: HttpHeaders | dict[str, str] | None = None, |
| 199 | payload: HttpPayload | None = None, |
| 200 | session: Session | None = None, |
| 201 | proxy_info: ProxyInfo | None = None, |
| 202 | timeout: timedelta | None = None, |
| 203 | ) -> AsyncGenerator[HttpResponse]: |
| 204 | validate_http_url(url) |
| 205 | |
| 206 | client = self._get_client(proxy_info.url if proxy_info else None, session.cookies.jar if session else None) |
| 207 | |
| 208 | try: |
| 209 | response = await client.request( |
| 210 | method=method, |
| 211 | url=url, |
| 212 | content=payload, |
| 213 | headers=dict(headers) if headers else None, |
| 214 | timeout=timeout.total_seconds() if timeout else None, |
| 215 | stream=True, |
| 216 | ) |
| 217 | except TimeoutException as exc: |
| 218 | raise asyncio.TimeoutError from exc |
| 219 | |
| 220 | try: |
| 221 | yield _ImpitResponse(response) |
| 222 | finally: |
| 223 | response.close() |
| 224 | |
| 225 | def _get_client(self, proxy_url: str | None, cookie_jar: CookieJar | None) -> AsyncClient: |
| 226 | """Retrieve or create an HTTP client for the given proxy URL. |
nothing calls this directly
no test coverage detected