1
0
mirror of https://github.com/kevin1024/vcrpy.git synced 2025-12-09 09:13:23 +00:00
Files
vcrpy/vcr/stubs/compat.py
2022-10-09 11:35:37 -03:00

27 lines
580 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))