diff -r e28221e52d24 Lib/http/client.py --- a/Lib/http/client.py Thu Apr 02 16:25:01 2015 +0200 +++ b/Lib/http/client.py Thu Apr 02 08:13:20 2015 -0700 @@ -784,9 +784,10 @@ self.debuglevel = level def _tunnel(self): - connect_str = "CONNECT %s:%d HTTP/1.0\r\n" % (self._tunnel_host, - self._tunnel_port) - connect_bytes = connect_str.encode("ascii") + connect_bytes = b'CONNECT %s:%d %s\r\n' % ( + self._tunnel_host.encode('idna'), + self._tunnel_port, + self._http_vsn_str.encode('ascii')) self.send(connect_bytes) for header, value in self._tunnel_headers.items(): header_str = "%s: %s\r\n" % (header, value) diff -r e28221e52d24 Lib/test/test_httplib.py --- a/Lib/test/test_httplib.py Thu Apr 02 16:25:01 2015 +0200 +++ b/Lib/test/test_httplib.py Thu Apr 02 08:13:20 2015 -0700 @@ -1488,6 +1488,16 @@ # This test should be removed when CONNECT gets the HTTP/1.1 blessing self.assertNotIn(b'Host: proxy.com', self.conn.sock.data) + def test_connect_with_tunnel_idna(self): + dest = '\u03b4\u03c0\u03b8.gr' + expected = 'CONNECT %s:%d HTTP/1.1\r\n'.encode('ascii') % ( + dest.encode('idna'), client.HTTP_PORT) + self.conn.set_tunnel(dest) + self.conn.request('HEAD', '/', '') + self.assertEqual(self.conn.sock.host, self.host) + self.assertEqual(self.conn.sock.port, client.HTTP_PORT) + self.assertIn(expected, self.conn.sock.data) + def test_connect_put_request(self): self.conn.set_tunnel('destination.com') self.conn.request('PUT', '/', '') diff -r e28221e52d24 Misc/NEWS --- a/Misc/NEWS Thu Apr 02 16:25:01 2015 +0200 +++ b/Misc/NEWS Thu Apr 02 08:13:20 2015 -0700 @@ -50,6 +50,10 @@ only calls fstat() once. Before fstat() was called twice, which was not necessary. +- Issue #22708: HTTPConnection now uses HTTP/1.1 to establish persistent + connections through proxy servers with CONNECT. Destination hosts are now + also IDNA-encoded. + Build -----