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: String = TODO("get some textual HAR-encoded data")
val har: Har = Har.parse(harText)
On the JVM, you can use the Path.readHar()
extension to read a HAR file:
import kotlin.io.path.*
import org.hildan.har.*
val harPath = Path("./my-recording.har")
val har: Har = harPath.readHar()
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)
.