当前位置: 首页>>代码示例>>Python>>正文


Python HistoryItem.request方法代码示例

本文整理汇总了Python中core.data.db.history.HistoryItem.request方法的典型用法代码示例。如果您正苦于以下问题:Python HistoryItem.request方法的具体用法?Python HistoryItem.request怎么用?Python HistoryItem.request使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在core.data.db.history.HistoryItem的用法示例。


在下文中一共展示了HistoryItem.request方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_clear

# 需要导入模块: from core.data.db.history import HistoryItem [as 别名]
# 或者: from core.data.db.history.HistoryItem import request [as 别名]
    def test_clear(self):

        url = URL("http://w3af.com/a/b/c.php")
        request = HTTPRequest(url, data="a=1")
        hdr = Headers([("Content-Type", "text/html")])
        res = HTTPResponse(200, "<html>", hdr, url, url)

        h1 = HistoryItem()
        h1.request = request
        res.set_id(1)
        h1.response = res
        h1.save()

        table_name = h1.get_table_name()
        db = get_default_temp_db_instance()

        self.assertTrue(db.table_exists(table_name))

        clear_result = h1.clear()

        self.assertTrue(clear_result)
        self.assertFalse(os.path.exists(h1._session_dir), "%s exists." % h1._session_dir)

        # Changed the meaning of clear a little bit... now it simply removes
        # all rows from the table, not the table itself
        self.assertTrue(db.table_exists(table_name))
开发者ID:zhuyue1314,项目名称:w3af,代码行数:28,代码来源:test_history.py

示例2: test_find

# 需要导入模块: from core.data.db.history import HistoryItem [as 别名]
# 或者: from core.data.db.history.HistoryItem import request [as 别名]
    def test_find(self):
        find_id = random.randint(1, 499)
        url = URL("http://w3af.org/a/b/foobar.php?foo=123")
        tag_value = rand_alnum(10)
        for i in xrange(0, 500):
            request = HTTPRequest(url, data="a=1")
            code = 200
            if i == find_id:
                code = 302

            hdr = Headers([("Content-Type", "text/html")])
            res = HTTPResponse(code, "<html>", hdr, url, url)
            h1 = HistoryItem()
            h1.request = request
            res.set_id(i)
            h1.response = res
            if i == find_id:
                h1.toggle_mark()
                h1.update_tag(tag_value)
            h1.save()
        h2 = HistoryItem()
        self.assertEqual(len(h2.find([("tag", "%" + tag_value + "%", "like")])), 1)
        self.assertEqual(len(h2.find([("code", 302, "=")])), 1)
        self.assertEqual(len(h2.find([("mark", 1, "=")])), 1)
        self.assertEqual(len(h2.find([("has_qs", 1, "=")])), 500)
        self.assertEqual(len(h2.find([("has_qs", 1, "=")], result_limit=10)), 10)
        results = h2.find([("has_qs", 1, "=")], result_limit=1, orderData=[("id", "desc")])
        self.assertEqual(results[0].id, 499)
        search_data = []
        search_data.append(("id", find_id + 1, "<"))
        search_data.append(("id", find_id - 1, ">"))
        self.assertEqual(len(h2.find(search_data)), 1)
开发者ID:zhuyue1314,项目名称:w3af,代码行数:34,代码来源:test_history.py

示例3: test_find

# 需要导入模块: from core.data.db.history import HistoryItem [as 别名]
# 或者: from core.data.db.history.HistoryItem import request [as 别名]
 def test_find(self):
     find_id = random.randint(1, 499)
     url = url_object('http://w3af.org/a/b/foobar.php?foo=123')
     tag_value = createRandAlNum(10)
     for i in xrange(0, 500):
         fr = FuzzReq(url, dc={'a': ['1']})
         code = 200
         if i == find_id:
             code = 302
         res = httpResponse(code, '<html>',{'Content-Type':'text/html'}, url, url)
         h1 = HistoryItem()
         h1.request = fr
         res.setId(i)
         h1.response = res
         if i == find_id:
             h1.toggleMark()
             h1.updateTag(tag_value)
         h1.save()
     h2 = HistoryItem()
     self.assertEqual(len(h2.find([('tag', "%"+tag_value+"%", 'like')])), 1)
     self.assertEqual(len(h2.find([('code', 302, '=')])), 1)
     self.assertEqual(len(h2.find([('mark', 1, '=')])), 1)
     self.assertEqual(len(h2.find([('has_qs', 1, '=')])), 500)
     self.assertEqual(len(h2.find([('has_qs', 1, '=')], resultLimit=10)), 10)
     results = h2.find([('has_qs', 1, '=')], resultLimit=1, orderData=[('id','desc')])
     self.assertEqual(results[0].id, 499)
     search_data = []
     search_data.append(('id', find_id + 1, "<"))
     search_data.append(('id', find_id - 1, ">"))
     self.assertEqual(len(h2.find(search_data)), 1)
开发者ID:1d3df9903ad,项目名称:w3af,代码行数:32,代码来源:test_history.py

示例4: store_in_cache

# 需要导入模块: from core.data.db.history import HistoryItem [as 别名]
# 或者: from core.data.db.history.HistoryItem import request [as 别名]
    def store_in_cache(request, response):
        hi = HistoryItem()
        
        # Set the request
        headers = dict(request.headers)
        headers.update(request.unredirected_hdrs)
    
        req = createFuzzableRequestRaw(method=request.get_method(),
                                      url=request.url_object,
                                      postData=str(request.get_data() or ''),
                                      headers=headers)
        hi.request = req

        # Set the response
        resp = response
        code, msg, hdrs, url, body, id = (resp.code, resp.msg, resp.info(),
                                          resp.geturl(), resp.read(), resp.id)
        # BUGBUG: This is where I create/log the responses that always have
        # 0.2 as the time!
        url_instance = url_object( url )
        resp = httpResponse.httpResponse(code, body, hdrs, url_instance,
                                         request.url_object, msg=msg, id=id,
                                         alias=gen_hash(request))
        hi.response = resp

        # Now save them
        try:
            hi.save()
        except KeyboardInterrupt, k:
            raise k
开发者ID:adambaldwin2,项目名称:test,代码行数:32,代码来源:localCache.py

示例5: logHttp

# 需要导入模块: from core.data.db.history import HistoryItem [as 别名]
# 或者: from core.data.db.history.HistoryItem import request [as 别名]
 def logHttp( self, request, response):
     historyItem = HistoryItem()
     try:
         historyItem.request = request
         historyItem.response = response
         historyItem.save()
     except KeyboardInterrupt, k:
         raise k
开发者ID:DavisHevin,项目名称:sqli_benchmark,代码行数:10,代码来源:gtkOutput.py

示例6: test_save_load

# 需要导入模块: from core.data.db.history import HistoryItem [as 别名]
# 或者: from core.data.db.history.HistoryItem import request [as 别名]
 def test_save_load(self):
     i = random.randint(1, 499)
     url = url_object('http://w3af.com/a/b/c.php')
     fr = FuzzReq(url, dc={'a': ['1']})
     res = httpResponse(200, '<html>',{'Content-Type':'text/html'}, url, url)
     h1 = HistoryItem()
     h1.request = fr
     res.setId(i)
     h1.response = res
     h1.save()
     h2 = HistoryItem()
     h2.load(i)
     self.assertEqual(h1.request, h2.request)
     self.assertEqual(h1.response.body, h2.response.body)
开发者ID:1d3df9903ad,项目名称:w3af,代码行数:16,代码来源:test_history.py

示例7: test_save_load

# 需要导入模块: from core.data.db.history import HistoryItem [as 别名]
# 或者: from core.data.db.history.HistoryItem import request [as 别名]
 def test_save_load(self):
     i = random.randint(1, 499)
     url = URL("http://w3af.com/a/b/c.php")
     request = HTTPRequest(url, data="a=1")
     hdr = Headers([("Content-Type", "text/html")])
     res = HTTPResponse(200, "<html>", hdr, url, url)
     h1 = HistoryItem()
     h1.request = request
     res.set_id(i)
     h1.response = res
     h1.save()
     h2 = HistoryItem()
     h2.load(i)
     self.assertEqual(h1.request, h2.request)
     self.assertEqual(h1.response.body, h2.response.body)
开发者ID:zhuyue1314,项目名称:w3af,代码行数:17,代码来源:test_history.py

示例8: test_clear_clear

# 需要导入模块: from core.data.db.history import HistoryItem [as 别名]
# 或者: from core.data.db.history.HistoryItem import request [as 别名]
    def test_clear_clear(self):

        url = URL("http://w3af.com/a/b/c.php")
        request = HTTPRequest(url, data="a=1")
        hdr = Headers([("Content-Type", "text/html")])
        res = HTTPResponse(200, "<html>", hdr, url, url)

        h1 = HistoryItem()
        h1.request = request
        res.set_id(1)
        h1.response = res
        h1.save()

        h1.clear()
        h1.clear()
开发者ID:zhuyue1314,项目名称:w3af,代码行数:17,代码来源:test_history.py

示例9: test_mark

# 需要导入模块: from core.data.db.history import HistoryItem [as 别名]
# 或者: from core.data.db.history.HistoryItem import request [as 别名]
 def test_mark(self):
     mark_id = random.randint(1, 499)
     url = url_object('http://w3af.org/a/b/c.php')
     for i in xrange(0, 500):
         fr = FuzzReq(url, dc={'a': ['1']})
         res = httpResponse(200, '<html>',{'Content-Type':'text/html'}, url, url)
         h1 = HistoryItem()
         h1.request = fr
         res.setId(i)
         h1.response = res
         if i == mark_id:
             h1.toggleMark()
         h1.save()
     h2 = HistoryItem()
     h2.load(mark_id)
     self.assertTrue(h2.mark)
开发者ID:1d3df9903ad,项目名称:w3af,代码行数:18,代码来源:test_history.py

示例10: test_delete

# 需要导入模块: from core.data.db.history import HistoryItem [as 别名]
# 或者: from core.data.db.history.HistoryItem import request [as 别名]
 def test_delete(self):
     i = random.randint(1, 499)
     url = url_object('http://w3af.com/a/b/c.php')
     fr = FuzzReq(url, dc={'a': ['1']})
     res = httpResponse(200, '<html>',{'Content-Type':'text/html'}, url, url)
     h1 = HistoryItem()
     h1.request = fr
     res.setId(i)
     h1.response = res
     h1.save()
     h1.delete(i)
     try:
         h2 = h1.read(i)
     except:
         h2 = None
     self.assertEqual(h2, None)
开发者ID:1d3df9903ad,项目名称:w3af,代码行数:18,代码来源:test_history.py

示例11: store_in_cache

# 需要导入模块: from core.data.db.history import HistoryItem [as 别名]
# 或者: from core.data.db.history.HistoryItem import request [as 别名]
    def store_in_cache(request, response):
        hi = HistoryItem()

        # Set the request
        req = create_fuzzable_request(request, add_headers=request.unredirected_hdrs)
        hi.request = req

        # Set the response
        resp = httpResponse.from_httplib_resp(response, original_url=request.url_object)
        resp.setId(response.id)
        resp.setAlias(gen_hash(request))
        hi.response = resp

        # Now save them
        try:
            hi.save()
        except KeyboardInterrupt, k:
            raise k
开发者ID:sanzomaldini,项目名称:w3af,代码行数:20,代码来源:localCache.py

示例12: test_tag

# 需要导入模块: from core.data.db.history import HistoryItem [as 别名]
# 或者: from core.data.db.history.HistoryItem import request [as 别名]
    def test_tag(self):
        tag_id = random.randint(501, 999)
        tag_value = createRandAlNum(10)
        url = url_object('http://w3af.org/a/b/c.php')

        for i in xrange(501, 1000):
            fr = FuzzReq(url, dc={'a': ['1']})
            res = httpResponse(200, '<html>',{'Content-Type':'text/html'}, url, url)
            h1 = HistoryItem()
            h1.request = fr
            res.setId(i)
            h1.response = res
            if i == tag_id:
                h1.updateTag(tag_value)
            h1.save()

        h2 = HistoryItem()
        h2.load(tag_id)
        self.assertEqual(h2.tag, tag_value)
开发者ID:1d3df9903ad,项目名称:w3af,代码行数:21,代码来源:test_history.py

示例13: test_tag

# 需要导入模块: from core.data.db.history import HistoryItem [as 别名]
# 或者: from core.data.db.history.HistoryItem import request [as 别名]
    def test_tag(self):
        tag_id = random.randint(501, 999)
        tag_value = rand_alnum(10)
        url = URL("http://w3af.org/a/b/c.php")

        for i in xrange(501, 1000):
            request = HTTPRequest(url, data="a=1")
            hdr = Headers([("Content-Type", "text/html")])
            res = HTTPResponse(200, "<html>", hdr, url, url)
            h1 = HistoryItem()
            h1.request = request
            res.set_id(i)
            h1.response = res
            if i == tag_id:
                h1.update_tag(tag_value)
            h1.save()

        h2 = HistoryItem()
        h2.load(tag_id)
        self.assertEqual(h2.tag, tag_value)
开发者ID:zhuyue1314,项目名称:w3af,代码行数:22,代码来源:test_history.py

示例14: store_in_cache

# 需要导入模块: from core.data.db.history import HistoryItem [as 别名]
# 或者: from core.data.db.history.HistoryItem import request [as 别名]
    def store_in_cache(request, response):
        # Create the http response object
        resp = HTTPResponse.from_httplib_resp(response,
                                              original_url=request.url_object)
        resp.set_id(response.id)
        resp.set_alias(gen_hash(request))

        hi = HistoryItem()
        hi.request = request
        hi.response = resp

        # Now save them
        try:
            hi.save()
        except sqlite3.Error, e:
            msg = 'A sqlite3 error was raised: "%s".' % e
            
            if 'disk' in str(e).lower():
                msg += ' Please check if your disk is full.'
                
            raise w3afMustStopException(msg)
开发者ID:Adastra-thw,项目名称:w3af,代码行数:23,代码来源:db.py

示例15: store_in_cache

# 需要导入模块: from core.data.db.history import HistoryItem [as 别名]
# 或者: from core.data.db.history.HistoryItem import request [as 别名]
    def store_in_cache(request, response):
        # Create the http response object
        resp = HTTPResponse.from_httplib_resp(response, original_url=request.url_object)
        resp.set_id(response.id)
        resp.set_alias(gen_hash(request))

        hi = HistoryItem()
        hi.request = request
        hi.response = resp

        # Now save them
        try:
            hi.save()
        except Exception, ex:
            msg = (
                "Exception while inserting request/response to the"
                " database: %s\nThe request/response that generated"
                " the error is: %s %s %s" % (ex, resp.get_id(), request.get_uri(), resp.get_code())
            )
            om.out.error(msg)
            raise Exception(msg)
开发者ID:kam40oz,项目名称:w3af,代码行数:23,代码来源:cache.py


注:本文中的core.data.db.history.HistoryItem.request方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。