def get(self, bookmark, url, accept_charset=False, use_proxy=False):
if url.startswith('ftp://'):
error, body = asyncio.run(_get_ftp(
- url, connect_timeout=self.connect_timeout,
- timeout=self.timeout,
+ url, timeout=self.ftp_timeout,
))
if error is not None:
error = str(error)
error, status, resp_headers, body = asyncio.run(get_http(
url, headers=headers, proxy=proxy,
- connect_timeout=self.connect_timeout, timeout=self.timeout,
+ timeout=self.timeout,
))
if error is not None or (status and status >= 400):
if error is None:
return '' # We don't store welcome message yet
-async def get_http(url, headers={}, proxy=None, connect_timeout=30, timeout=60):
- timeout = aiohttp.ClientTimeout(connect=connect_timeout, total=timeout)
+async def get_http(url, headers={}, proxy=None, timeout=60):
+ timeout = aiohttp.ClientTimeout(connect=timeout, total=timeout)
try:
async with aiohttp.ClientSession(timeout=timeout) as session:
async with session.get(
return e, None, None, None
-async def _get_ftp(url, connect_timeout=30, timeout=60):
+async def _get_ftp(url, timeout=60):
split_results = urlsplit(url)
path = split_results.path or '/'
user = split_results.username or 'anonymous'
try:
async with aioftp.Client.context(
host, port, user=user, password=password,
- socket_timeout=connect_timeout, path_timeout=timeout,
+ socket_timeout=timeout, path_timeout=timeout,
) as client:
async for _path, _info in client.list(path):
lines.append('%s %s' % (_info, _path))
curl.setopt(pycurl.SSL_VERIFYHOST, 2)
curl.setopt(curl.CAINFO, certifi.where())
# Set timeouts to avoid hanging too long
- curl.setopt(pycurl.CONNECTTIMEOUT, self.connect_timeout)
- curl.setopt(pycurl.TIMEOUT, self.timeout)
+ if url.startswith('ftp://'):
+ timeout = self.ftp_timeout
+ else:
+ timeout = self.timeout
+ curl.setopt(pycurl.CONNECTTIMEOUT, timeout)
+ curl.setopt(pycurl.TIMEOUT, timeout)
# Parse Last-Modified
curl.setopt(pycurl.OPT_FILETIME, 1)