Created
April 24, 2020 04:28
-
-
Save eupendra/a898aaaac71ac855a63ba9498dfa5048 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_headers(s, sep=': ', strip_cookie=True,strip_cl=True, strip_headers:list=[]) -> dict(): | |
l = s.split('\n') | |
d = dict() | |
for kv in l: | |
if kv: | |
k = kv.split(sep)[0] | |
v = kv.split(sep)[1] | |
if strip_cookie and k == 'cookie': continue | |
if strip_cl and k == 'content-length': continue | |
if k in strip_headers: continue | |
d[k] = v | |
return d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment