pyshark
pyshark copied to clipboard
How to iterate all the HTTP headers?
I want list all the headers in http layer. I can access specific header like this
cap = pyshark.FileCapture(path_to_file, display_filter='http')
p = cap[1]
http = p['http']
http.server
how I do something like this:
for h in http:
print(h)
hope help. @secondaviv
if hasattr(packet.http, 'request_line'):
lists_request = packet.http.request_line.all_fields
map={}
for _, request_header in enumerate(lists_request):
header_key = request_header.showname_key
header_value = request_header.showname_value.replace('\\n', '').replace('\\r', '')
map[header_key]=header_value