Created
July 31, 2020 13:38
-
-
Save roymartinezblanco/b3b111a39a9bc3c4b8c463bf8efa8c40 to your computer and use it in GitHub Desktop.
Helper Function to fund headers in har
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 findHeader(req,headertype,headername,op = None): | |
value = "None" | |
if headertype == 'response': | |
for h in req['response']['headers']: | |
if op == 'in': | |
if headername in h['name']: | |
value = h['value'] | |
break | |
else: | |
if headername == h['name']: | |
value = h['value'] | |
break | |
if headertype == 'cdn-timing': | |
value = 0 | |
for h in req['response']['headers']: | |
if op == 'eq': | |
if 'server-timing' in h['name']: | |
if headername in h['value']: | |
value = int(h['value'].split(';')[1].split('=')[1]) | |
break | |
if value is None: | |
return 0 | |
return value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment