1
0
mirror of https://github.com/kevin1024/vcrpy.git synced 2025-12-08 16:53:23 +00:00
Files
vcrpy/vcr/stubs/compat.py
2023-05-05 10:14:46 -03:00

27 lines
578 B
Python

import http.client
from io import BytesIO
"""
The python3 http.client api moved some stuff around, so this is an abstraction
layer that tries to cope with this move.
"""
def get_header(message, name):
return message.getallmatchingheaders(name)
def get_header_items(message):
for key, values in get_headers(message):
for value in values:
yield key, value
def get_headers(message):
for key in set(message.keys()):
yield key, message.get_all(key)
def get_httpmessage(headers):
return http.client.parse_headers(BytesIO(headers))