json - Parsing HAR file to get a table of HTTP header values -
i parsing har file (chrome devtools generated) using jq. objective "table" (or csv output nice also) list of values of specific http headers returned server, per request url.
to list of request urls, can do:
cat har.json | jq '.log.entries[].request.url'
now like, each request, column urls , next columns corresponding content-encoding , content-type http header values returned in response/headers section.
i managed http headers values following command:
cat har.json | jq '.log.entries[].response.headers[] | select(.name=="content-encoding" or .name=="content-type") | .value'
now mix url , header values. how can that?
there difficulty here because headers may not returned in same order http server.
you use filter this:
[ "url", "content-type", "content-encoding" ], (.log.entries[] | [ .request.url, ((.response.headers[] | select(.name == "content-type").value) // ""), ((.response.headers[] | select(.name == "content-encoding").value) // "") ]) | @csv
the key here content type , encoding, need perform search headers separately if want control order appear. there, need format in such way output csv.
Comments
Post a Comment