HTTP Archive (HAR) command-line tool
The curl tool has many options, but it can be difficult to use. HAR is a great format
for debugging and logging, but it's very static, and just sits there. This is where
harcurl comes in. To make a request, simply fill out a HAR entry with the
request fields you are sending, and harcurl will:
- read the JSON object from
stdin - convert it to
libcurloptions - call curl_easy_setopt so that
libcurlcan use them - call curl_easy_perform
- call curl_easy_getinfo to fill in the timings
- convert the response back to JSON
- dumps the JSON object to
stdout
It is a very simply idea, but hopefully one that helps people to understand, inspect, and use: CURL, HAR, and HTTP.
libcurlfor obvious reasons (all HTTP logic is handled by it).janssonfor JSON parsing, reading and writing.glibfor byte-array utils, utf8 validation, etc.zlibfor GZIP compression utils.
$ cat > req.json <<EOF
{
"request": {
"method": "GET",
"url": "http://httpbin.org/get"
}
}
EOF
$ harcurl < req.json > resp.json
HAR-1.2 is a great specification. It does miss a couple things, however, so harcurl uses a few extensions to it where appropriate.
entry.request._headersTextentry.request._requestLineentry.request._requestLineshould be the same as{method} {_urlParts.path} {httpVersion}entry.request._urlPartsentry.request.urlshould be the same as{_urlParts.scheme}://{_urlParts.authority}{_urlParts.path}entry.response._headersTextentry.response._contentTypeentry.response._statusLineentry.response._statusLineshould be the same as{httpVersion} {status} {statusText}