Beispiel #1
0
def test_headers_access_gets_a_value():
    headers = BaseHeaders(b"Foo: Bar")
    expected = b"Bar"
    actual = headers[b'Foo']
    assert actual == expected
Beispiel #2
0
def test_headers_dont_unicodify_cookie():
    headers = BaseHeaders(b"Cookie: somecookiedata")
    expected = b"somecookiedata"
    actual = headers[b'Cookie']
    assert actual == expected
Beispiel #3
0
def test_baseheaders_loads_cookies_as_str():
    headers = BaseHeaders(b"Cookie: key=value")
    assert headers.cookie[str('key')].value == str('value')
Beispiel #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
Beispiel #5
0
def test_headers_access_is_case_insensitive():
    headers = BaseHeaders(b"Foo: Bar")
    expected = b"Bar"
    actual = headers[b'foo']
    assert actual == expected
Beispiel #6
0
def test_headers_reject_CR_injection_from_add():
    with raises(CRLFInjection):
        BaseHeaders().add(b'foo', b'\rbar')
Beispiel #7
0
def test_headers_reject_LF_injection():
    with raises(CRLFInjection):
        BaseHeaders()[b'foo'] = b'\nbar'
Beispiel #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!'
Beispiel #9
0
def test_headers_reject_CR_injection():
    with raises(CRLFInjection):
        BaseHeaders(b'')[b'foo'] = b'\rbar'
Beispiel #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!'