feat: Semaine 9
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
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
|
||||
Reference in New Issue
Block a user