663
663
def proxy_bypass(self, host):
664
664
"""Check if host should be proxied or not"""
665
if self._debuglevel > 0:
666
print 'Is [%r] proxied or not' % host
667
665
no_proxy = self.get_proxy('no')
668
666
if no_proxy is None:
670
668
hhost, hport = urllib.splitport(host)
671
if self._debuglevel > 0:
672
print 'hhost [%r], hport [%r]' % (hhost, hport)
673
669
# Does host match any of the domains mentionned in
674
670
# no_proxy The rules about what is authorized in no_proxy
675
671
# are fuzzy (too say the least). We try to allows most
676
672
# commonly seen values.
677
673
for domain in no_proxy.split(','):
678
674
dhost, dport = urllib.splitport(domain)
679
if self._debuglevel > 0:
680
print 'dhost [%r], dport [%r]' % (hhost, hport)
675
if hport == dport or dport is None:
682
676
# Protect glob chars
683
677
dhost = dhost.replace(".", r"\.")
684
678
dhost = dhost.replace("*", r".*")
685
679
dhost = dhost.replace("?", r".")
686
if re.match(domain, hhost, re.IGNORECASE):
680
if re.match(dhost, hhost, re.IGNORECASE):
688
682
# Nevertheless, there are platform specific ways to
689
683
# ignore proxies...