forked from satisfice/jq_cookbook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
har-scan-req-postdata-full.jq
44 lines (34 loc) · 1.07 KB
/
har-scan-req-postdata-full.jq
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# For HAR files only.
# This script traverses a HAR file and tries to interpret the content of each POST request as a json.
# It outputs the URL of each request, with an index number and pretty-printed version of the json.
#
# Save the original input, because we will need it, below...
. as $original
|
# get all the entries
.log.entries
|
# get all the index numbers for the entries
keys
|
# for each entry, save the index number for later...
.[] as $index
|
# ...then go back to the original input and pick out the entry for that index number
$original.log.entries[$index]
|
# check if the content type include "json" or "text"
# (the reason we check for text type is that in some webapps jsons are mislabeled as text type)
select(
.request.postData.text != null and .request.postData.text != ""
)
|
# now we are ready for output...
# this outputs the entry index
(["Entry", $index]| join(": ")),
# url
.request.url,
# print the content
.request.postData.text,
# separator
"\n============================================="