From f0cf5463c85bd38243ac1539487d7118003a790e Mon Sep 17 00:00:00 2001 From: Konstantin Lopuhin Date: Wed, 20 Jan 2016 12:23:48 +0300 Subject: [PATCH] cleanup http11 tunneling connection after #1678 - construct string and then convert to bytes --- scrapy/core/downloader/handlers/http11.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/scrapy/core/downloader/handlers/http11.py b/scrapy/core/downloader/handlers/http11.py index a4d5a28c8..ad3285a32 100644 --- a/scrapy/core/downloader/handlers/http11.py +++ b/scrapy/core/downloader/handlers/http11.py @@ -92,11 +92,9 @@ class TunnelingTCP4ClientEndpoint(TCP4ClientEndpoint): def requestTunnel(self, protocol): """Asks the proxy to open a tunnel.""" - tunnelReq = ( - b'CONNECT ' + - to_bytes(self._tunneledHost, encoding='ascii') + b':' + - to_bytes(str(self._tunneledPort)) + - b' HTTP/1.1\r\n') + tunnelReq = to_bytes( + 'CONNECT %s:%s HTTP/1.1\r\n' % ( + self._tunneledHost, self._tunneledPort), encoding='ascii') if self._proxyAuthHeader: tunnelReq += \ b'Proxy-Authorization: ' + self._proxyAuthHeader + b'\r\n'