Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

Test http schemaless proxy

ajaymittur28f53f06020b74
diff --git a/tests/test_downloader_handlers.py b/tests/test_downloader_handlers.py
index 51deb20f4..5854659dd 100644
--- a/tests/test_downloader_handlers.py
+++ b/tests/test_downloader_handlers.py
@@ -131,6 +131,7 @@ class ContentLengthHeaderResource(resource.Resource):
A testing resource which renders itself as the value of the Content-Length
header from the request.
"""
+
def render(self, request):
return request.requestHeaders.getRawHeaders(b"content-length")[0]
@@ -186,6 +187,7 @@ class EmptyContentTypeHeaderResource(resource.Resource):
A testing resource which renders itself as the value of request body
without content-type header in response.
"""
+
def render(self, request):
request.setHeader("content-type", "")
return request.content.read()
@@ -733,6 +735,16 @@ class Http11ProxyTestCase(HttpProxyTestCase):
timeout = yield self.assertFailure(d, error.TimeoutError)
self.assertIn(domain, timeout.osError)
+ def test_download_with_proxy_without_http_scheme(self):
+ def _test(response):
+ self.assertEqual(response.status, 200)
+ self.assertEqual(response.url, request.url)
+ self.assertEqual(response.body, b'http://example.com')
+
+ http_proxy = self.getURL('').replace('http:', '')
+ request = Request('http://example.com', meta={'proxy': http_proxy})
+ return self.download_request(request, Spider('foo')).addCallback(_test)
+
class HttpDownloadHandlerMock: