def test_add_referer(self): request = Request() url_record = URLRecord() url_record.parent_url = 'http://example.com/' url_record.url = 'http://example.com/image.png' WebProcessorSession._add_referrer(request, url_record) self.assertEqual('http://example.com/', request.fields['Referer'])
def test_add_referer_https_to_http(self): request = Request() url_record = URLRecord() url_record.parent_url = 'https://example.com/' url_record.url = 'http://example.com/image.png' WebProcessorSession._add_referrer(request, url_record) self.assertNotIn('referer', request.fields)
def test_add_referer(self): request = Request() url_record = URLRecord(url=None, status=None, try_count=None, level=None, top_url=None, status_code=None, referrer='http://example.com/', inline=None, link_type=None, post_data=None, filename=None) url_info = URLInfo.parse('http://example.com/') WebProcessorSession._add_referrer(request, url_record, url_info) self.assertEqual('http://example.com/', request.fields['Referer'])
def test_add_referer(self): request = Request() url_record = URLRecord( url=None, status=None, try_count=None, level=None, top_url=None, status_code=None, referrer='http://example.com/', inline=None, link_type=None, post_data=None, filename=None ) url_info = URLInfo.parse('http://example.com/') WebProcessorSession._add_referrer(request, url_record, url_info) self.assertEqual('http://example.com/', request.fields['Referer'])