Skip to content

Instantly share code, notes, and snippets.

@roymartinezblanco
Created July 31, 2020 13:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roymartinezblanco/b3b111a39a9bc3c4b8c463bf8efa8c40 to your computer and use it in GitHub Desktop.
Save roymartinezblanco/b3b111a39a9bc3c4b8c463bf8efa8c40 to your computer and use it in GitHub Desktop.
Helper Function to fund headers in har
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