aboutsummaryrefslogtreecommitdiffstats
path: root/tests/wpt/web-platform-tests/xhr/resources/inspect-headers.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/wpt/web-platform-tests/xhr/resources/inspect-headers.py')
-rw-r--r--tests/wpt/web-platform-tests/xhr/resources/inspect-headers.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/tests/wpt/web-platform-tests/xhr/resources/inspect-headers.py b/tests/wpt/web-platform-tests/xhr/resources/inspect-headers.py
index 36ef17488ce..72c1a7f1d7a 100644
--- a/tests/wpt/web-platform-tests/xhr/resources/inspect-headers.py
+++ b/tests/wpt/web-platform-tests/xhr/resources/inspect-headers.py
@@ -8,13 +8,14 @@ def get_response(raw_headers, filter_value, filter_name):
# Python 3. <http.client.HTTPMessage> doesn't have 'headers" attribute or equivalent
# [https://bugs.python.org/issue4773].
# In Python 2, variable raw_headers.headers returns a completely uninterpreted list of lines
- # contained in the header. In Python 3, raw_headers.as_string() returns entire formatted
- # message as a string. Here is to construct an equivalent "headers" variable to support tests
- # in Python 3.
+ # contained in the header. In Python 3, raw_headers.raw_items() returns the (name, value)
+ # header pairs without modification. Here is to construct an equivalent "headers" variable to
+ # support tests in Python 3.
if PY3:
- header_list = [
- isomorphic_encode(s + u'\r\n') for s in raw_headers.as_string().splitlines() if s
- ]
+ header_list = []
+ for field in raw_headers.raw_items():
+ header = b"%s: %s\r\n" % (isomorphic_encode(field[0]), isomorphic_encode(field[1]))
+ header_list.append(header)
else:
header_list = raw_headers.headers
for line in header_list: