mirror of
https://github.com/django/daphne.git
synced 2024-11-24 08:53:43 +03:00
Further improve flaky header tests
This commit is contained in:
parent
db68c43de1
commit
0572b1dbcd
|
@ -16,7 +16,7 @@ class TestHTTPResponse(DaphneTestCase):
|
||||||
Lowercases and sorts headers, and strips transfer-encoding ones.
|
Lowercases and sorts headers, and strips transfer-encoding ones.
|
||||||
"""
|
"""
|
||||||
return sorted([
|
return sorted([
|
||||||
(name.lower(), value)
|
(name.lower(), value.strip())
|
||||||
for name, value in headers
|
for name, value in headers
|
||||||
if name.lower() != "transfer-encoding"
|
if name.lower() != "transfer-encoding"
|
||||||
])
|
])
|
||||||
|
|
|
@ -52,7 +52,7 @@ class TestWebsocket(DaphneTestCase):
|
||||||
# {name: [value1, value2, ...]} and check if they're equal.
|
# {name: [value1, value2, ...]} and check if they're equal.
|
||||||
transformed_scope_headers = collections.defaultdict(list)
|
transformed_scope_headers = collections.defaultdict(list)
|
||||||
for name, value in scope["headers"]:
|
for name, value in scope["headers"]:
|
||||||
transformed_scope_headers[name] = []
|
transformed_scope_headers.setdefault(name, [])
|
||||||
# Make sure to split out any headers collapsed with commas
|
# Make sure to split out any headers collapsed with commas
|
||||||
for bit in value.split(b","):
|
for bit in value.split(b","):
|
||||||
if bit.strip():
|
if bit.strip():
|
||||||
|
@ -61,8 +61,8 @@ class TestWebsocket(DaphneTestCase):
|
||||||
for name, value in (headers or []):
|
for name, value in (headers or []):
|
||||||
expected_name = name.lower().strip().encode("ascii")
|
expected_name = name.lower().strip().encode("ascii")
|
||||||
expected_value = value.strip().encode("ascii")
|
expected_value = value.strip().encode("ascii")
|
||||||
transformed_request_headers[expected_name] = []
|
|
||||||
# Make sure to split out any headers collapsed with commas
|
# Make sure to split out any headers collapsed with commas
|
||||||
|
transformed_request_headers.setdefault(expected_name, [])
|
||||||
for bit in expected_value.split(b","):
|
for bit in expected_value.split(b","):
|
||||||
if bit.strip():
|
if bit.strip():
|
||||||
transformed_request_headers[expected_name].append(bit.strip())
|
transformed_request_headers[expected_name].append(bit.strip())
|
||||||
|
|
Loading…
Reference in New Issue
Block a user