Skip to content

Instantly share code, notes, and snippets.

@x-N0
Created March 25, 2022 01:40
Show Gist options
  • Save x-N0/7c5de77f9849156c4cd5f4abde46a3bd to your computer and use it in GitHub Desktop.
Save x-N0/7c5de77f9849156c4cd5f4abde46a3bd to your computer and use it in GitHub Desktop.
Browser Headers to Dict PYTHON
def raw_headers_to_dict(raw:str)->dict:
header_dict = {}
header_list = raw.split('\n')
for each in header_list:
key, value = each.split(': ')
header_dict.update({f"{key}": f"{value}"})
return header_dict
# Usage:
dict_headers = raw_headers_to_dict(raw_headers)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment