예제 #1
0
def test_headers_access_gets_a_value():
    headers = BaseHeaders(b"Foo: Bar")
    expected = b"Bar"
    actual = headers[b'Foo']
    assert actual == expected
예제 #2
0
def test_headers_dont_unicodify_cookie():
    headers = BaseHeaders(b"Cookie: somecookiedata")
    expected = b"somecookiedata"
    actual = headers[b'Cookie']
    assert actual == expected
예제 #3
0
def test_baseheaders_loads_cookies_as_str():
    headers = BaseHeaders(b"Cookie: key=value")
    assert headers.cookie[str('key')].value == str('value')
예제 #4
0
def test_headers_access_gets_last_value():
    headers = BaseHeaders([(b"Foo", b"Bar"), (b"Foo", b"Baz")])
    expected = b"Baz"
    actual = headers[b'Foo']
    assert actual == expected
예제 #5
0
def test_headers_access_is_case_insensitive():
    headers = BaseHeaders(b"Foo: Bar")
    expected = b"Bar"
    actual = headers[b'foo']
    assert actual == expected
예제 #6
0
def test_headers_reject_CR_injection_from_add():
    with raises(CRLFInjection):
        BaseHeaders().add(b'foo', b'\rbar')
예제 #7
0
def test_headers_reject_LF_injection():
    with raises(CRLFInjection):
        BaseHeaders()[b'foo'] = b'\nbar'
예제 #8
0
def test_headers_can_be_raw_when_non_ascii():
    headers = BaseHeaders({b'Foo': b'b\xc3\xabar', b'Oh': b'Yeah!'})
    assert headers.raw == b'Foo: b\xc3\xabar\r\nOh: Yeah!'
예제 #9
0
def test_headers_reject_CR_injection():
    with raises(CRLFInjection):
        BaseHeaders(b'')[b'foo'] = b'\rbar'
예제 #10
0
def test_headers_can_be_raw_when_non_ascii():
    headers = BaseHeaders(b'Foo: b\xc3\xabar\r\nOh: Yeah!')
    assert headers.raw == b'Foo: b\xc3\xabar\r\nOh: Yeah!'