mirror of https://github.com/scrapy/scrapy.git
fix #2552 by improving request schema check on its initialization
This commit is contained in:
parent
1d5c270ce8
commit
f701f5b0db
|
|
@ -66,7 +66,7 @@ class Request(object_ref):
|
|||
s = safe_url_string(url, self.encoding)
|
||||
self._url = escape_ajax(s)
|
||||
|
||||
if ':' not in self._url:
|
||||
if ('://' not in self._url) and (not self._url.startswith('data:')):
|
||||
raise ValueError('Missing scheme in request url: %s' % self._url)
|
||||
|
||||
url = property(_get_url, obsolete_setter(_set_url, 'url'))
|
||||
|
|
|
|||
|
|
@ -52,6 +52,8 @@ class RequestTest(unittest.TestCase):
|
|||
|
||||
def test_url_no_scheme(self):
|
||||
self.assertRaises(ValueError, self.request_class, 'foo')
|
||||
self.assertRaises(ValueError, self.request_class, '/foo/')
|
||||
self.assertRaises(ValueError, self.request_class, '/foo:bar')
|
||||
|
||||
def test_headers(self):
|
||||
# Different ways of setting headers attribute
|
||||
|
|
|
|||
Loading…
Reference in New Issue