A Kotlin multiplatform library to parse HAR (HTTP Archive) files, including support for the web socket traffic format.
Add the dependency:
dependencies {
implementation("org.hildan.har:har-parser:$version")
}
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)
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)
.