mirror of https://github.com/scrapy/scrapy.git
Raise ValueError if url has no scheme in Request constructor
This commit is contained in:
parent
88e33ad0ad
commit
c4a607fc78
|
|
@ -60,6 +60,8 @@ class Request(object_ref):
|
|||
self._url = safe_url_string(unicode_url, self.encoding)
|
||||
else:
|
||||
raise TypeError('Request url must be str or unicode, got %s:' % type(url).__name__)
|
||||
if ':' not in self._url:
|
||||
raise ValueError('Missing scheme in request url: %s' % self._url)
|
||||
|
||||
url = property(_get_url, deprecated_setter(_set_url, 'url'))
|
||||
|
||||
|
|
|
|||
|
|
@ -42,6 +42,9 @@ class RequestTest(unittest.TestCase):
|
|||
assert r.headers is not headers
|
||||
self.assertEqual(r.headers["caca"], "coco")
|
||||
|
||||
def test_url_no_scheme(self):
|
||||
self.assertRaises(ValueError, self.request_class, 'foo')
|
||||
|
||||
def test_headers(self):
|
||||
# Different ways of setting headers attribute
|
||||
url = 'http://www.scrapy.org'
|
||||
|
|
|
|||
Loading…
Reference in New Issue