Exemplo n.º 1
0
def test_filter_by_body():
    f = context.gen_filter_by_body(['ct', 'sexy'])
    fn = context.gen_filter_by_body(['nct', 'sexy'])

    # Test request bodies
    r = Request()
    r.start_line = 'GET /sexy HTTP/1.1'
    r.headers['Header'] = 'sexy'
    r.body = 'foo'
    assert not f(r)
    assert fn(r)

    r.body = 'sexy'
    assert f(r)
    assert not fn(r)

    # Test response bodies
    r = Request()
    rsp = Response()
    rsp.start_line = 'HTTP/1.1 200 OK'
    rsp.headers['sexy'] = 'sexy'
    r.start_line = 'GET /sexy HTTP/1.1'
    r.headers['Header'] = 'sexy'
    r.response = rsp
    assert not f(r)
    assert fn(r)

    rsp.body = 'sexy'
    assert f(r)
    assert not fn(r)
Exemplo n.º 2
0
def test_filter_by_body():
    f = context.gen_filter_by_body(['ct', 'sexy'])
    fn = context.gen_filter_by_body(['nct', 'sexy'])
    
    # Test request bodies
    r = Request()
    r.start_line = 'GET /sexy HTTP/1.1'
    r.headers['Header'] = 'sexy'
    r.body = 'foo'
    assert not f(r)
    assert fn(r)

    r.body = 'sexy'
    assert f(r)
    assert not fn(r)

    # Test response bodies
    r = Request()
    rsp = Response()
    rsp.start_line = 'HTTP/1.1 200 OK'
    rsp.headers['sexy'] = 'sexy'
    r.start_line = 'GET /sexy HTTP/1.1'
    r.headers['Header'] = 'sexy'
    r.response = rsp
    assert not f(r)
    assert fn(r)

    rsp.body = 'sexy'
    assert f(r)
    assert not fn(r)
Exemplo n.º 3
0
def req():
    r = Request()
    r.start_line = "GET / HTTP/1.1"
    r.host = "www.ffffff.eeeeee"
    r.body = "AAAA"
    return r
Exemplo n.º 4
0
def req():
    r = Request()
    r.start_line = 'GET / HTTP/1.1'
    return r
Exemplo n.º 5
0
def req():
    r = Request()
    r.start_line = 'GET / HTTP/1.1'
    return r
Exemplo n.º 6
0
def req():
    r = Request()
    r.start_line = 'GET / HTTP/1.1'
    r.host = 'www.ffffff.eeeeee'
    r.body = 'AAAA'
    return r