/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/transport/http/_urllib2_wrappers.py

Merge fetch-spec-everything-not-in-other.

Show diffs side-by-side

added added

removed removed

Lines of Context:
598
598
                        'Bad status line received',
599
599
                        orig_error=exc_val)
600
600
                elif (isinstance(exc_val, socket.error) and len(exc_val.args)
601
 
                      and exc_val.args[0] in (errno.ECONNRESET, 10054)):
 
601
                      and exc_val.args[0] in (errno.ECONNRESET, 10053, 10054)):
 
602
                      # 10053 == WSAECONNABORTED
 
603
                      # 10054 == WSAECONNRESET
602
604
                    raise errors.ConnectionReset(
603
605
                        "Connection lost while sending request.")
604
606
                else:
940
942
        return None
941
943
 
942
944
    def proxy_bypass(self, host):
943
 
        """Check if host should be proxied or not"""
 
945
        """Check if host should be proxied or not.
 
946
 
 
947
        :returns: True to skip the proxy, False otherwise.
 
948
        """
944
949
        no_proxy = self.get_proxy_env_var('no', default_to=None)
 
950
        bypass = self.evaluate_proxy_bypass(host, no_proxy)
 
951
        if bypass is None:
 
952
            # Nevertheless, there are platform-specific ways to
 
953
            # ignore proxies...
 
954
            return urllib.proxy_bypass(host)
 
955
        else:
 
956
            return bypass
 
957
 
 
958
    def evaluate_proxy_bypass(self, host, no_proxy):
 
959
        """Check the host against a comma-separated no_proxy list as a string.
 
960
 
 
961
        :param host: ``host:port`` being requested
 
962
 
 
963
        :param no_proxy: comma-separated list of hosts to access directly.
 
964
 
 
965
        :returns: True to skip the proxy, False not to, or None to
 
966
            leave it to urllib.
 
967
        """
945
968
        if no_proxy is None:
 
969
            # All hosts are proxied
946
970
            return False
947
971
        hhost, hport = urllib.splitport(host)
948
972
        # Does host match any of the domains mentioned in
950
974
        # are fuzzy (to say the least). We try to allow most
951
975
        # commonly seen values.
952
976
        for domain in no_proxy.split(','):
 
977
            domain = domain.strip()
 
978
            if domain == '':
 
979
                continue
953
980
            dhost, dport = urllib.splitport(domain)
954
981
            if hport == dport or dport is None:
955
982
                # Protect glob chars
958
985
                dhost = dhost.replace("?", r".")
959
986
                if re.match(dhost, hhost, re.IGNORECASE):
960
987
                    return True
961
 
        # Nevertheless, there are platform-specific ways to
962
 
        # ignore proxies...
963
 
        return urllib.proxy_bypass(host)
 
988
        # Nothing explicitly avoid the host
 
989
        return None
964
990
 
965
991
    def set_proxy(self, request, type):
966
992
        if self.proxy_bypass(request.get_host()):