Using HAR files with wiretap

Review or validated captured traffic via HAR files

use wiretap offline with HAR files

HTTP Archive (HAR) files can be loaded into wiretap for review in the Monitor UI, or for validation against an OpenAPI specification.

Reviewing the HAR files

By loading in a HAR file and loading the Monitor UI you can review the captured traffic. The UI will stream the traffic to you as if it were being sent live, and you can use the UI to filter the traffic, or to search for anything specific.

The monitor UI doesn’t know the difference between live traffic and HAR file traffic. Everything you can do live, you can do with the HAR file.

Validating the HAR files

You can also validate the HAR file against an OpenAPI specification. This will check that the traffic in the HAR file matches the specification, and will report any errors or warnings.

Loading a HAR file

Use the --har / z flag to load a HAR file into wiretap:

wiretap --har myharfile.har

This will boot wiretap into a non-proxy mode and load the HAR file into memory. You can then use the Monitor UI to review the traffic.

If you reload the page, the HAR data will be re-sent - you may end up with duplicate traffic. To reset, just clear the application state from the controls icon.

Validating a HAR file

To validate a HAR file against an OpenAPI specification,

  • Use the --har / z flag to load the HAR file into wiretap
  • Use the --spec / s flag to load the OpenAPI specification
  • Use the --har-validate / g flag to validate the HAR file against the OpenAPI specification
  • Use the --har-allow / j flag to define as many base paths you want to validate against
wiretap --har myharfile.har \ --spec myspec.yaml \ --har-validate \ --har-allow /users \ --har-allow /burgers

wiretap wil then validate the all the applicable requests and corresponding responses in the HAR file against the OpenAPI specification. It will print the results to the console and concurrently to a JSON file with a default name of wiretap-report.json (which can be changed with the --report / a flag)

All of these values can be set in the config file as well.