pyshark icon indicating copy to clipboard operation
pyshark copied to clipboard

How to iterate all the HTTP headers?

Open secondaviv opened this issue 3 years ago • 1 comments

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)

secondaviv avatar Apr 19 '21 16:04 secondaviv

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

linkingli avatar Sep 26 '21 11:09 linkingli