1
0
mirror of https://github.com/kevin1024/vcrpy.git synced 2025-12-08 16:53:23 +00:00

change response format

This commit is contained in:
Kevin McCarthy
2014-05-03 19:54:00 -10:00
parent 1f99ede46f
commit a65da12aeb
2 changed files with 8 additions and 7 deletions

View File

@@ -2,13 +2,13 @@ import six
def convert_to_bytes(resp):
resp = convert_headers_to_bytes(resp)
#resp = convert_headers_to_bytes(resp)
resp = convert_body_to_bytes(resp)
return resp
def convert_to_unicode(resp):
resp = convert_headers_to_unicode(resp)
#resp = convert_headers_to_unicode(resp)
resp = convert_body_to_unicode(resp)
return resp

View File

@@ -48,15 +48,16 @@ def parse_headers(header_list):
HTTPMessage
"""
header_string = b""
for k, v in header_list.items():
for v in v:
header_string += k.encode('utf-8') + b":" + v.encode('utf-8') + b"\r\n"
for key, values in header_list.items():
for v in values:
header_string += key.encode('utf-8') + b":" + v.encode('utf-8') + b"\r\n"
return compat.get_httpmessage(header_string)
def serialize_headers(response):
out = {}
for k, v in response.getheaders():
out.setdefault(k, []).append(v)
for key in response.msg.keys():
out.setdefault(key, [])
out[key].extend(response.msg.getheaders(key))
return out