| 1195 | # x509 info). The header and x509 fields may be None. |
| 1196 | |
| 1197 | def get_host_info(self, host): |
| 1198 | |
| 1199 | x509 = {} |
| 1200 | if isinstance(host, tuple): |
| 1201 | host, x509 = host |
| 1202 | |
| 1203 | auth, host = urllib.parse._splituser(host) |
| 1204 | |
| 1205 | if auth: |
| 1206 | auth = urllib.parse.unquote_to_bytes(auth) |
| 1207 | auth = base64.encodebytes(auth).decode("utf-8") |
| 1208 | auth = "".join(auth.split()) # get rid of whitespace |
| 1209 | extra_headers = [ |
| 1210 | ("Authorization", "Basic " + auth) |
| 1211 | ] |
| 1212 | else: |
| 1213 | extra_headers = [] |
| 1214 | |
| 1215 | return host, extra_headers, x509 |
| 1216 | |
| 1217 | ## |
| 1218 | # Connect to server. |