HARcURL

The HTTP archiving (HAR) file transfer tool.

Welcome

Welcome to the harcurl homepage.

In order to understand what harcurl is, there are some prerequisites you should know:

  • HTTP is the way the Web works.
  • HAR-1.2 is a specification of a JSON-based format for HTTP archives.
  • JSON is a subset of JavaScript language syntax used for simple data exchange.
  • jansson is a library for reading and writing JSON data.
  • libcurl is a multiprotocol file transfer library (including HTTP).
  • curl is a command-line tool that uses libcurl.
  • glib is a library that provides the core application building blocks for GNOME.
  • You don't need to know all of these, just HTTP and JSON should be enough.

All of these are used together in harcurl to make the tool easier to use. There are several goals of the harcurl project:

  1. To evangelize the HAR format.
  2. To make HAR more active than just an archival format (which IMHO is as passive as it gets).
  3. To make HTTP transfers easier to understand (JSON helps by being able to see complex structures).
  4. To make curl and libcurl easier to use.

    For example, instead of typing all of the arguments on the command-line, as some people do, you can capture a HAR request and HAR response with Chrome or Firefox and copy-and-paste the request to input into harcurl, and since it's the same format you don't have to edit much (except perhaps the Date header).

Getting Started

The only way to get harcurl right now is to build it from source. The source code is available from GitHub or the link above.

git clone https://github.com/andydude/harcurl.git

Make sure you have libcurl, jansson, glib, and zlib installed, then (in the harcurl directory) run

./autogen.sh && ./configure && make && sudo make install

There are some examples in the tests directory to get you started.

Usage

The harcurl tool accepts requests on stdin, and prints responses to stdout. The format of the request and response are both specified in the HAR-1.2 specification. Obviously, almost every property is optional on input, even though the HAR spec says it is required, since one of the jobs of harcurl is to fill in the rest of the data from the response. The only 2 properties that are required are method and url.

The recommended usage is to build a JSON file either by hand, or by generating one with your favorite programming language, then feed that to harcurl on stdin.

echo '
{
  "request" {
    "method": "GET",
    "url": "http://httpbin.org/get"
  }
}' | harcurl

The simplest way to use harcurl is to call it with the shell command:

harcurl < req.json > resp.json

Advanced Usage

There are some differences between HAR-1.2 and the input format to harcurl. For reference, we can call this new format "HAR-1.3-alpha" or something.

One major difference is that almost everything is optional on input, because most of the fields are filled in by harcurl. There are also some properties that are NOT specified by HAR-1.2, but are meaningful to harcurl. For example:

  • entry.request.headerText (output if the -v option is given)
  • entry.response.headerText (output if the -v option is given)
  • entry.request.requestLine (output if the -v option is given)
  • entry.response.statusLine (output if the -v option is given)
  • entry.request.postData.text (input to send as raw data, instead of form parameters)
  • entry.request.postData.params (input to send as form parameters, instead of raw data)
  • entry.request.postData.params.headers (input for headers to attach to a specific form datum, not the request headers) -- not in HAR-1.2