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:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user