mirror of
https://github.com/kevin1024/vcrpy.git
synced 2025-12-10 01:25:34 +00:00
change response format
This commit is contained in:
@@ -2,13 +2,13 @@ import six
|
|||||||
|
|
||||||
|
|
||||||
def convert_to_bytes(resp):
|
def convert_to_bytes(resp):
|
||||||
resp = convert_headers_to_bytes(resp)
|
#resp = convert_headers_to_bytes(resp)
|
||||||
resp = convert_body_to_bytes(resp)
|
resp = convert_body_to_bytes(resp)
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
|
|
||||||
def convert_to_unicode(resp):
|
def convert_to_unicode(resp):
|
||||||
resp = convert_headers_to_unicode(resp)
|
#resp = convert_headers_to_unicode(resp)
|
||||||
resp = convert_body_to_unicode(resp)
|
resp = convert_body_to_unicode(resp)
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
|
|||||||
@@ -48,15 +48,16 @@ def parse_headers(header_list):
|
|||||||
HTTPMessage
|
HTTPMessage
|
||||||
"""
|
"""
|
||||||
header_string = b""
|
header_string = b""
|
||||||
for k, v in header_list.items():
|
for key, values in header_list.items():
|
||||||
for v in v:
|
for v in values:
|
||||||
header_string += k.encode('utf-8') + b":" + v.encode('utf-8') + b"\r\n"
|
header_string += key.encode('utf-8') + b":" + v.encode('utf-8') + b"\r\n"
|
||||||
return compat.get_httpmessage(header_string)
|
return compat.get_httpmessage(header_string)
|
||||||
|
|
||||||
def serialize_headers(response):
|
def serialize_headers(response):
|
||||||
out = {}
|
out = {}
|
||||||
for k, v in response.getheaders():
|
for key in response.msg.keys():
|
||||||
out.setdefault(k, []).append(v)
|
out.setdefault(key, [])
|
||||||
|
out[key].extend(response.msg.getheaders(key))
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user