Scrapy, a fast high-level web crawling & scraping framework for Python.
Remove `noconnect` deprecate code
Laerte Pereirae769532644e1
diff --git a/scrapy/core/downloader/handlers/http11.py b/scrapy/core/downloader/handlers/http11.pyindex 6b8a18f1a..f07f0780e 100644--- a/scrapy/core/downloader/handlers/http11.py+++ b/scrapy/core/downloader/handlers/http11.py@@ -3,7 +3,6 @@import ipaddressimport loggingimport re-import warningsfrom contextlib import suppressfrom io import BytesIOfrom time import time@@ -22,7 +21,7 @@ from zope.interface import implementerfrom scrapy import signalsfrom scrapy.core.downloader.contextfactory import load_context_factory_from_settingsfrom scrapy.core.downloader.webclient import _parse-from scrapy.exceptions import ScrapyDeprecationWarning, StopDownload+from scrapy.exceptions import StopDownloadfrom scrapy.http import Headersfrom scrapy.responsetypes import responsetypesfrom scrapy.utils.python import to_bytes, to_unicode@@ -279,17 +278,7 @@ class ScrapyAgent:proxyScheme, proxyNetloc, proxyHost, proxyPort, proxyParams = _parse(proxy)scheme = _parse(request.url)[0]proxyHost = to_unicode(proxyHost)- omitConnectTunnel = b'noconnect' in proxyParams- if omitConnectTunnel:- warnings.warn(- "Using HTTPS proxies in the noconnect mode is deprecated. "- "If you use Zyte Smart Proxy Manager, it doesn't require "- "this mode anymore, so you should update scrapy-crawlera "- "to scrapy-zyte-smartproxy and remove '?noconnect' "- "from the Zyte Smart Proxy Manager URL.",- ScrapyDeprecationWarning,- )- if scheme == b'https' and not omitConnectTunnel:+ if scheme == b'https':proxyAuth = request.headers.get(b'Proxy-Authorization', None)proxyConf = (proxyHost, proxyPort, proxyAuth)return self._TunnelingAgent(@@ -302,8 +291,6 @@ class ScrapyAgent:)else:proxyScheme = proxyScheme or b'http'- proxyHost = to_bytes(proxyHost, encoding='ascii')- proxyPort = to_bytes(str(proxyPort), encoding='ascii')proxyURI = urlunparse((proxyScheme, proxyNetloc, proxyParams, '', '', ''))return self._ProxyAgent(reactor=reactor,diff --git a/scrapy/core/downloader/handlers/http2.py b/scrapy/core/downloader/handlers/http2.pyindex 7bb88a193..3f1b36e92 100644--- a/scrapy/core/downloader/handlers/http2.py+++ b/scrapy/core/downloader/handlers/http2.py@@ -1,4 +1,3 @@-import warningsfrom time import timefrom typing import Optional, Type, TypeVarfrom urllib.parse import urldefrag@@ -69,19 +68,8 @@ class ScrapyH2Agent:if proxy:_, _, proxy_host, proxy_port, proxy_params = _parse(proxy)scheme = _parse(request.url)[0]- proxy_host = proxy_host.decode()- omit_connect_tunnel = b'noconnect' in proxy_params- if omit_connect_tunnel:- warnings.warn(- "Using HTTPS proxies in the noconnect mode is not "- "supported by the downloader handler. If you use Zyte "- "Smart Proxy Manager, it doesn't require this mode "- "anymore, so you should update scrapy-crawlera to "- "scrapy-zyte-smartproxy and remove '?noconnect' from the "- "Zyte Smart Proxy Manager URL."- )-- if scheme == b'https' and not omit_connect_tunnel:++ if scheme == b'https':# ToDoraise NotImplementedError('Tunneling via CONNECT method using HTTP/2.0 is not yet supported')return self._ProxyAgent(diff --git a/tests/test_downloader_handlers.py b/tests/test_downloader_handlers.pyindex 883960084..c69bd3da1 100644--- a/tests/test_downloader_handlers.py+++ b/tests/test_downloader_handlers.py@@ -24,7 +24,7 @@ from scrapy.core.downloader.handlers.http import HTTPDownloadHandlerfrom scrapy.core.downloader.handlers.http10 import HTTP10DownloadHandlerfrom scrapy.core.downloader.handlers.http11 import HTTP11DownloadHandlerfrom scrapy.core.downloader.handlers.s3 import S3DownloadHandler-from scrapy.exceptions import NotConfigured, ScrapyDeprecationWarning+from scrapy.exceptions import NotConfiguredfrom scrapy.http import Headers, HtmlResponse, Requestfrom scrapy.http.response.text import TextResponsefrom scrapy.responsetypes import responsetypes@@ -757,18 +757,6 @@ class HttpProxyTestCase(unittest.TestCase):request = Request('http://example.com', meta={'proxy': http_proxy})return self.download_request(request, Spider('foo')).addCallback(_test)- def test_download_with_proxy_https_noconnect(self):- def _test(response):- self.assertEqual(response.status, 200)- self.assertEqual(response.url, request.url)- self.assertEqual(response.body, b'https://example.com')-- http_proxy = f'{self.getURL("")}?noconnect'- request = Request('https://example.com', meta={'proxy': http_proxy})- with self.assertWarnsRegex(ScrapyDeprecationWarning,- r'Using HTTPS proxies in the noconnect mode is deprecated'):- return self.download_request(request, Spider('foo')).addCallback(_test)-def test_download_without_proxy(self):def _test(response):self.assertEqual(response.status, 200)diff --git a/tests/test_downloader_handlers_http2.py b/tests/test_downloader_handlers_http2.pyindex 3a9db3ee5..079267535 100644--- a/tests/test_downloader_handlers_http2.py+++ b/tests/test_downloader_handlers_http2.py@@ -242,21 +242,6 @@ class Https2ProxyTestCase(Http11ProxyTestCase):def getURL(self, path):return f"{self.scheme}://{self.host}:{self.portno}/{path}"- def test_download_with_proxy_https_noconnect(self):- def _test(response):- self.assertEqual(response.status, 200)- self.assertEqual(response.url, request.url)- self.assertEqual(response.body, b'/')-- http_proxy = f"{self.getURL('')}?noconnect"- request = Request('https://example.com', meta={'proxy': http_proxy})- with self.assertWarnsRegex(- Warning,- r'Using HTTPS proxies in the noconnect mode is not supported by the '- r'downloader handler.'- ):- return self.download_request(request, Spider('foo')).addCallback(_test)-@defer.inlineCallbacksdef test_download_with_proxy_https_timeout(self):with self.assertRaises(NotImplementedError):