Commit 1b8e72f3 authored by Michael Hanselmann's avatar Michael Hanselmann

rapi.testutils: Add utility to format HTTP headers

Once again this will be used by forthcoming RAPI test.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 0351944b
......@@ -134,6 +134,17 @@ def _GetPathFromUri(uri):
return None
def _FormatHeaders(headers):
"""Formats HTTP headers.
@type headers: sequence of strings
@rtype: string
"""
assert compat.all(": " in header for header in headers)
return "\n".join(headers)
class FakeCurl:
"""Fake cURL object.
......@@ -167,7 +178,7 @@ class FakeCurl:
writefn = self._opts[pycurl.WRITEFUNCTION]
if pycurl.HTTPHEADER in self._opts:
baseheaders = "\n".join(self._opts[pycurl.HTTPHEADER])
baseheaders = _FormatHeaders(self._opts[pycurl.HTTPHEADER])
else:
baseheaders = ""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment