changeset: 96341:3b6e0720a69d branch: 2.7 parent: 96336:17d3bbde60d2 user: Serhiy Storchaka date: Thu May 28 22:37:13 2015 +0300 files: Lib/httplib.py Lib/test/test_httplib.py Misc/NEWS description: Issue #22095: Fixed HTTPConnection.set_tunnel with default port. The port value in the host header was set to "None". Patch by Demian Brecht. diff -r 17d3bbde60d2 -r 3b6e0720a69d Lib/httplib.py --- a/Lib/httplib.py Thu May 28 12:45:31 2015 -0500 +++ b/Lib/httplib.py Thu May 28 22:37:13 2015 +0300 @@ -772,8 +772,7 @@ if self.sock: raise RuntimeError("Can't setup tunnel for established connection.") - self._tunnel_host = host - self._tunnel_port = port + self._tunnel_host, self._tunnel_port = self._get_hostport(host, port) if headers: self._tunnel_headers = headers else: @@ -802,8 +801,8 @@ self.debuglevel = level def _tunnel(self): - (host, port) = self._get_hostport(self._tunnel_host, self._tunnel_port) - self.send("CONNECT %s:%d HTTP/1.0\r\n" % (host, port)) + self.send("CONNECT %s:%d HTTP/1.0\r\n" % (self._tunnel_host, + self._tunnel_port)) for header, value in self._tunnel_headers.iteritems(): self.send("%s: %s\r\n" % (header, value)) self.send("\r\n") diff -r 17d3bbde60d2 -r 3b6e0720a69d Lib/test/test_httplib.py --- a/Lib/test/test_httplib.py Thu May 28 12:45:31 2015 -0500 +++ b/Lib/test/test_httplib.py Thu May 28 22:37:13 2015 +0300 @@ -842,10 +842,12 @@ self.assertEqual(conn.sock.host, 'proxy.com') self.assertEqual(conn.sock.port, 80) - self.assertTrue('CONNECT destination.com' in conn.sock.data) - self.assertTrue('Host: destination.com' in conn.sock.data) + self.assertIn('CONNECT destination.com', conn.sock.data) + # issue22095 + self.assertNotIn('Host: destination.com:None', conn.sock.data) + self.assertIn('Host: destination.com', conn.sock.data) - self.assertTrue('Host: proxy.com' not in conn.sock.data) + self.assertNotIn('Host: proxy.com', conn.sock.data) conn.close() diff -r 17d3bbde60d2 -r 3b6e0720a69d Misc/NEWS --- a/Misc/NEWS Thu May 28 12:45:31 2015 -0500 +++ b/Misc/NEWS Thu May 28 22:37:13 2015 +0300 @@ -22,6 +22,9 @@ Library ------- +- Issue #22095: Fixed HTTPConnection.set_tunnel with default port. The port + value in the host header was set to "None". Patch by Demian Brecht. + - Issue #24257: Fixed segmentation fault in sqlite3.Row constructor with faked cursor type.