Fix remove_entity_headers
helper function (#1415)
* Fix `remove_entity_headers` helper function * Add test for `remove_entity_headers` helper function
This commit is contained in:
parent
096c44b910
commit
f7adc5f84c
|
@ -128,6 +128,6 @@ def remove_entity_headers(headers, allowed=("content-location", "expires")):
|
||||||
headers = {
|
headers = {
|
||||||
header: value
|
header: value
|
||||||
for header, value in headers.items()
|
for header, value in headers.items()
|
||||||
if not is_entity_header(header) and header.lower() not in allowed
|
if not is_entity_header(header) or header.lower() in allowed
|
||||||
}
|
}
|
||||||
return headers
|
return headers
|
||||||
|
|
|
@ -34,3 +34,41 @@ def test_is_hop_by_hop_header():
|
||||||
)
|
)
|
||||||
for header, expected in tests:
|
for header, expected in tests:
|
||||||
assert helpers.is_hop_by_hop_header(header) is expected
|
assert helpers.is_hop_by_hop_header(header) is expected
|
||||||
|
|
||||||
|
|
||||||
|
def test_remove_entity_headers():
|
||||||
|
tests = (
|
||||||
|
(
|
||||||
|
{},
|
||||||
|
{}
|
||||||
|
),
|
||||||
|
(
|
||||||
|
{
|
||||||
|
"Allow": "GET, POST, HEAD",
|
||||||
|
},
|
||||||
|
{}
|
||||||
|
),
|
||||||
|
(
|
||||||
|
{
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"Expires": "Wed, 21 Oct 2015 07:28:00 GMT",
|
||||||
|
"Foo": "Bar"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Expires": "Wed, 21 Oct 2015 07:28:00 GMT",
|
||||||
|
"Foo": "Bar"
|
||||||
|
},
|
||||||
|
),
|
||||||
|
(
|
||||||
|
{
|
||||||
|
"Allow": "GET, POST, HEAD",
|
||||||
|
"Content-Location": "/test"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Content-Location": "/test"
|
||||||
|
},
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
for header, expected in tests:
|
||||||
|
assert helpers.remove_entity_headers(header) == expected
|
||||||
|
|
Loading…
Reference in New Issue
Block a user