mirror of
https://github.com/scrapy/scrapy.git
synced 2025-02-25 07:43:43 +00:00
Skipping cookie retrieval for non http requests
This commit is contained in:
parent
e1f0d0d45d
commit
fb770852e8
@ -23,6 +23,8 @@ class CookieJar(object):
|
|||||||
# the cookiejar implementation iterates through all domains
|
# the cookiejar implementation iterates through all domains
|
||||||
# instead we restrict to potential matches on the domain
|
# instead we restrict to potential matches on the domain
|
||||||
req_host = urlparse_cached(request).hostname
|
req_host = urlparse_cached(request).hostname
|
||||||
|
if not req_host:
|
||||||
|
return
|
||||||
|
|
||||||
if not IPV4_RE.search(req_host):
|
if not IPV4_RE.search(req_host):
|
||||||
hosts = potential_domain_matches(req_host)
|
hosts = potential_domain_matches(req_host)
|
||||||
|
@ -129,3 +129,8 @@ class CookiesMiddlewareTest(TestCase):
|
|||||||
req5_3 = Request('http://scrapytest.org/some-redirected-path')
|
req5_3 = Request('http://scrapytest.org/some-redirected-path')
|
||||||
assert self.mw.process_request(req5_3, self.spider) is None
|
assert self.mw.process_request(req5_3, self.spider) is None
|
||||||
self.assertEquals(req5_3.headers.get('Cookie'), 'C1=value1')
|
self.assertEquals(req5_3.headers.get('Cookie'), 'C1=value1')
|
||||||
|
|
||||||
|
#skip cookie retrieval for not http request
|
||||||
|
req6 = Request('file:///scrapy/sometempfile')
|
||||||
|
assert self.mw.process_request(req6, self.spider) is None
|
||||||
|
self.assertEquals(req6.headers.get('Cookie'), None)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user