A Kotlin library to create HAR network log files.
implementation 'com.github.homespotter:hardyharhar:LATEST_RELEASE'
private val entries = mutableListOf<HarEntry>()
fun addEntry() {
val harRequest: HarRequest = HarRequest(
method = "GET",
url = "http://example.com",
httpVersion = "HTTP/1.1",
)
val harResponse: HarResponse = HarResponse(
status = 200,
statusText = "OK",
httpVersion = "HTTP/1.1",
)
entries.add(HarEntry(
request = harRequest,
response = harResponse,
startedDateTime = Date(),
time = 200 // duration of network request in ms,
))
}
fun writeHarFile() {
val file = File("treasure_map.har")
DefaultHarWriter().writeHarLogToFile(HarLog(entries = entries), file)
}
You may need to add the following to your proguard-rules.pro
-keepattributes *Annotation*, InnerClasses
-dontnote kotlinx.serialization.SerializationKt
-keep,includedescriptorclasses class dev.percula.hardyharhar.**$$serializer { *; }
-keepclassmembers class dev.percula.hardyharhar.** {
*** Companion;
}
-keepclasseswithmembers class dev.percula.hardyharhar.** {
kotlinx.serialization.KSerializer serializer(...);
}
HardyHarHar is based on Har-Java