def smart_get(self, bookmark, url, accept_charset=False):
split_results = urlsplit(url)
+ url_proto = split_results.scheme
url_host = split_results.hostname
if url_host in self.proxy_error:
return 'see prev. error', None, None, None, None
use_proxy = False
- if url_host in self.proxy_ok:
- use_proxy = True
+ if self.proxy:
+ split_proxy = urlsplit(self.proxy)
+ proxy_proto = split_proxy.scheme
+ # Do not route ftp requests via http(s) proxy;
+ # socks5 proxies are ok.
+ if (url_proto == 'ftp'):
+ use_proxy = proxy_proto.startswith('socks5')
+ else: # http(s)
+ use_proxy = True
+
+ if use_proxy and url_host in self.proxy_ok:
self.log(' Immediately trying with the proxy')
error, http_status_code, redirect_to, headers, content = \
self.get(bookmark, url,
not url_host.startswith('127.')
):
self.log(' Error : %s' % error)
- if self.proxy and http_status_code != 404:
- use_proxy = True
+ if use_proxy and http_status_code != 404:
self.log(' Retrying with the proxy...')
error, http_status_code, redirect_to, headers, content = \
self.get(bookmark, url,