コード例 #1
0
ファイル: test_flow.py プロジェクト: alxsoares/mitmproxy
def test_decoded():
    r = tutils.treq()
    assert r.content == "content"
    assert not r.headers["content-encoding"]
    r.encode("gzip")
    assert r.headers["content-encoding"]
    assert r.content != "content"
    with flow.decoded(r):
        assert not r.headers["content-encoding"]
        assert r.content == "content"
    assert r.headers["content-encoding"]
    assert r.content != "content"

    with flow.decoded(r):
        r.content = "foo"

    assert r.content != "foo"
    r.decode()
    assert r.content == "foo"
コード例 #2
0
ファイル: test_flow.py プロジェクト: bnewbold/haip-mitmproxy
def test_decoded():
    r = tutils.treq()
    assert r.content == "content"
    assert not r.headers["content-encoding"]
    r.encode("gzip")
    assert r.headers["content-encoding"]
    assert r.content != "content"
    with flow.decoded(r):
        assert not r.headers["content-encoding"]
        assert r.content == "content"
    assert r.headers["content-encoding"]
    assert r.content != "content"

    with flow.decoded(r):
        r.content = "foo"

    assert r.content != "foo"
    r.decode()
    assert r.content == "foo"
コード例 #3
0
ファイル: clamav.py プロジェクト: 0day1day/HoneyProxy
def response(context, flow):
    with decoded(flow.response):
        clamd_result = clamd.scan_stream(flow.response.content)
    if clamd_result:
        print "Virus detected: ",clamd_result
        flow.response.content = "HoneyProxy has detected a virus and stopped this page from loading: %s" % str(clamd_result["stream"])
        flow.response.headers["Content-Length"] = [str(len(flow.response.content))]
        flow.response.headers["Content-Type"] = ["text/html"]
        del flow.response.headers["Content-Disposition"]
        del flow.response.headers["Content-Encoding"]
        flow.response.code = 403
        flow.response.msg = "Forbidden"
コード例 #4
0
ファイル: clamav.py プロジェクト: ohyeah521/HoneyProxy-1
def response(context, flow):
    with decoded(flow.response):
        clamd_result = clamd.scan_stream(flow.response.content)
    if clamd_result:
        print "Virus detected: ", clamd_result
        flow.response.content = "HoneyProxy has detected a virus and stopped this page from loading: %s" % str(
            clamd_result["stream"])
        flow.response.headers["Content-Length"] = [
            str(len(flow.response.content))
        ]
        flow.response.headers["Content-Type"] = ["text/html"]
        del flow.response.headers["Content-Disposition"]
        del flow.response.headers["Content-Encoding"]
        flow.response.code = 403
        flow.response.msg = "Forbidden"