def get_file_head(self, url: str) -> Optional[CIMultiDictProxy]:
"""Make a HEAD request to get a 'content-length' and 'accept-ranges' headers."""
self.log_debug('Getting a HEAD for url: {!s}.'.format(url))
try:
async with aiohttp.ClientSession(loop=self._loop) as session:
async with session.request(hdrs.METH_HEAD, url) as res: # type: aiohttp.ClientResponse
return res.headers
except Exception as exc:
self.log_debug("Could not get a HEAD for the {!r}. Error: {!r}.".format(url, exc))
return None
评论列表
文章目录