I'm using pyshark for parsing .pcapng files. My aim is to find the HTTP requests (packet numbers and http request line) to whom the responses were not 200 OK (or include errors).
My approach is to find all the packets that are HTTP responses and response.code is different from (200 or 401) -I'm not interested in 401 Unauthorized for now- and then for each packet find the relative HTTP request.
I am able to retrieve the list of error responses successfully by applying a display filter to my capture file as follows:
cap = pyshark.FileCapture(file,display_filter='http.response.code!=200 && http.response.code!=401')
However, I can't seem to find a way to retrieve the http request from the response packet. In Wireshark, I am able to find this data by selecting the http response packet and pressing on 'follow TCP stream'. I'm looking for suggestions to achieve my approach or perhaps another way to retrieve the same result.