示例#1
0
    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'])
示例#2
0
    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)
示例#3
0
    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'])
示例#4
0
    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'])