/har-parser

A Kotlin library to parse HAR (HTTP Archive) files

Primary LanguageKotlinMIT LicenseMIT

har-parser

Maven central version Github Build GitHub license

A Kotlin multiplatform library to parse HAR (HTTP Archive) files, including support for the web socket traffic format.

Setup

Add the dependency:

dependencies {
    implementation("org.hildan.har:har-parser:$version")
}

Usage

Parse HAR text

You can get the data as text first, and then parse it using:

import org.hildan.har.*

val harText = TODO("get some textual HAR-encoded data")
val har = Har.parse(harText)

Parse HAR files

On the JVM, you can use the Path.parseHar() extensions to parse a HAR file:

import kotlin.io.path.*
import org.hildan.har.*

val harPath = Path("./my-recording.har")
val har = harPath.parseHar()

har.log.entries.forEach {
    println("${it.request.method} ${it.response.status} ${it.request.url}")
}

You can also write a HAR file using Path.writeHar(Har).