Example #1
0
    def _create_terminate_response(self, http_response):
        content = render('spiderman_end.html', {})

        headers = Headers((
            ('Connection', 'close'),
            ('Content-type', 'text/html'),
        ))

        http_response = HTTPResponse(200, content.encode('utf-8'), headers,
                                     http_response.get_uri(),
                                     http_response.get_uri(),
                                     msg='Ok')
        return http_response
Example #2
0
    def _create_terminate_response(self, http_response):
        content = render('spiderman_end.html', {})

        headers = Headers((
            ('Connection', 'close'),
            ('Content-type', 'text/html'),
        ))

        http_response = HTTPResponse(200, content.encode('utf-8'), headers,
                                     http_response.get_uri(),
                                     http_response.get_uri(),
                                     msg='Ok')
        return http_response
Example #3
0
    def _create_favicon_response(self, http_response):
        favicon = os.path.join(ROOT_PATH,
                               'plugins/crawl/spider_man/favicon.ico')

        headers = Headers((
            ('Connection', 'close'),
            ('Content-type', 'image/vnd.microsoft.icon'),
        ))

        http_response = HTTPResponse(200,
                                     file(favicon, 'rb').read(),
                                     headers,
                                     http_response.get_uri(),
                                     http_response.get_uri(),
                                     msg='Ok')
        return http_response
Example #4
0
    def _create_favicon_response(self, http_response):
        favicon = os.path.join(ROOT_PATH,
                               'plugins/crawl/spider_man/favicon.ico')

        headers = Headers((
            ('Connection', 'close'),
            ('Content-type', 'image/vnd.microsoft.icon'),
        ))

        http_response = HTTPResponse(200,
                                     file(favicon, 'rb').read(),
                                     headers,
                                     http_response.get_uri(),
                                     http_response.get_uri(),
                                     msg='Ok')
        return http_response
Example #5
0
    def test_response_body(self):
        body = "hello user!"
        headers = Headers([("content-type", "text/html")])
        response = HTTPResponse(200, body, headers, self.url, self.url, _id=1)

        option_list = self.plugin.get_options()
        option_list["expressions"].set_value("sb/user/notluser/")
        self.plugin.set_options(option_list)

        mod_request = self.plugin.mangle_request(self.request)
        mod_response = self.plugin.mangle_response(response)

        self.assertEqual(mod_request.get_headers(), self.request.get_headers())
        self.assertEqual(mod_response.get_headers(), response.get_headers())

        self.assertEqual(mod_request.get_uri(), self.request.get_uri())
        self.assertEqual(mod_response.get_uri(), response.get_uri())

        self.assertEqual(mod_response.get_body(), "hello notluser!")
Example #6
0
    def test_response_body(self):
        body = 'hello user!'
        headers = Headers([('content-type', 'text/html')])
        response = HTTPResponse(200, body, headers, self.url, self.url, _id=1)

        option_list = self.plugin.get_options()
        option_list['expressions'].set_value('sb/user/notluser/')        
        self.plugin.set_options(option_list)
        
        mod_request = self.plugin.mangle_request(self.request)
        mod_response = self.plugin.mangle_response(response)
        
        self.assertEqual(mod_request.get_headers(), self.request.get_headers())
        self.assertEqual(mod_response.get_headers(), response.get_headers())

        self.assertEqual(mod_request.get_uri(), self.request.get_uri())
        self.assertEqual(mod_response.get_uri(), response.get_uri())

        self.assertEqual(mod_response.get_body(), 'hello notluser!')
Example #7
0
    def test_response_body(self):
        body = 'hello user!'
        headers = Headers([('content-type', 'text/html')])
        response = HTTPResponse(200, body, headers, self.url, self.url, _id=1)

        option_list = self.plugin.get_options()
        option_list['expressions'].set_value('sb/user/notluser/')        
        self.plugin.set_options(option_list)
        
        mod_request = self.plugin.mangle_request(self.request)
        mod_response = self.plugin.mangle_response(response)
        
        self.assertEqual(mod_request.get_headers(), self.request.get_headers())
        self.assertEqual(mod_response.get_headers(), response.get_headers())

        self.assertEqual(mod_request.get_uri(), self.request.get_uri())
        self.assertEqual(mod_response.get_uri(), response.get_uri())

        self.assertEqual(mod_response.get_body(), 'hello notluser!')