async def _request(self, proxy_address, timeout) -> tuple: checker_result = CheckerResult() if self.url is None: raise Exception() headers = {'User-Agent': async_requests.get_random_user_agent()} conn = ProxyConnector(remote_resolve=True) with aiohttp.ClientSession( connector=conn, request_class=ProxyClientRequest) as session: async with session.request( self.request_type, self.url, proxy=proxy_address, timeout=timeout, headers=headers) as \ response: is_working = await self._check(response, checker_result) return is_working, checker_result
async def _request(method, url, proxy_url, timeout, session: aiohttp.ClientSession = None): headers = {'User-Agent': async_requests.get_random_user_agent()} conn = ProxyConnector(remote_resolve=True) with aiohttp.ClientSession(connector=conn, request_class=ProxyClientRequest) as session: async with session.request(method, url, proxy=proxy_url, timeout=timeout) as response: # async with session.request(method, url, timeout=timeout, headers=headers, proxy=proxy_url) as response: status = response.status text = await response.text() return async_requests.Response(status, text)
async def _request(self, proxy_address, timeout) -> tuple: checker_result = CheckerResult() if self.url is None: raise Exception() headers = {"User-Agent": async_requests.get_random_user_agent()} conn = BaseChecker.get_aiohttp_connector() async with aiohttp.ClientSession( connector=conn, connector_owner=False, request_class=ProxyClientRequest) as session: async with session.request(self.request_type, self.url, proxy=proxy_address, timeout=timeout, headers=headers) as response: is_working = await self.validate(response, checker_result) return is_working, checker_result