Exemplo n.º 1
0
    def get_host_info(self, host):

        x509 = {}
        if isinstance(host, tuple):
            host, x509 = host

        auth, host = urllib_parse.splituser(host)

        if auth:
            auth = urllib_parse.unquote_to_bytes(auth)
            auth = base64.encodebytes(auth).decode("utf-8")
            auth = "".join(auth.split())  # get rid of whitespace
            extra_headers = [("Authorization", "Basic " + auth)]
        else:
            extra_headers = []

        return host, extra_headers, x509
Exemplo n.º 2
0
    def get_host_info(self, host):

        x509 = {}
        if isinstance(host, tuple):
            host, x509 = host

        auth, host = urllib_parse.splituser(host)

        if auth:
            auth = urllib_parse.unquote_to_bytes(auth)
            auth = base64.encodebytes(auth).decode("utf-8")
            auth = "".join(auth.split())  # get rid of whitespace
            extra_headers = [("Authorization", "Basic " + auth)]
        else:
            extra_headers = []

        return host, extra_headers, x509
Exemplo n.º 3
0
 def test_unquote_to_bytes(self):
     result = urllib_parse.unquote_to_bytes('abc%20def')
     self.assertEqual(result, b'abc def')
     result = urllib_parse.unquote_to_bytes('')
     self.assertEqual(result, b'')
Exemplo n.º 4
0
 def test_unquote_to_bytes(self):
     result = urllib_parse.unquote_to_bytes('abc%20def')
     self.assertEqual(result, b'abc def')
     result = urllib_parse.unquote_to_bytes('')
     self.assertEqual(result, b'')