108 host = host.strip('.') |
108 host = host.strip('.') |
109 host = re.sub(r'\.+', '.', host).lower() |
109 host = re.sub(r'\.+', '.', host).lower() |
110 if host.isdigit(): |
110 if host.isdigit(): |
111 try: |
111 try: |
112 host = socket.inet_ntoa(struct.pack("!I", int(host))) |
112 host = socket.inet_ntoa(struct.pack("!I", int(host))) |
113 except Exception: |
113 except Exception: # secok |
114 pass |
114 pass |
115 if host.startswith('0x') and '.' not in host: |
115 if host.startswith('0x') and '.' not in host: |
116 try: |
116 try: |
117 host = socket.inet_ntoa(struct.pack("!I", int(host, 16))) |
117 host = socket.inet_ntoa(struct.pack("!I", int(host, 16))) |
118 except Exception: |
118 except Exception: # secok |
119 pass |
119 pass |
120 quotedPath = quote(path) |
120 quotedPath = quote(path) |
121 quotedHost = quote(host) |
121 quotedHost = quote(host) |
122 if port is not None: |
122 if port is not None: |
123 quotedHost = '{0}:{1}'.format(quotedHost, port) |
123 quotedHost = '{0}:{1}'.format(quotedHost, port) |