16 lines
372 B
Python
16 lines
372 B
Python
import re # RegEx
|
|
|
|
def extract_header(payload):
|
|
try:
|
|
header_brut = payload[:payload.index(b"\r\n\r\n") + 2]
|
|
except ValueError:
|
|
return None
|
|
|
|
header = dict(re.findall(
|
|
r"(?P<cle>.*?): (?P<valeur>.*?)\r\n",
|
|
header_brut.decode(errors="ignore")
|
|
))
|
|
|
|
if "Content-Type" not in header:
|
|
return None
|
|
return header |