Pre-configure client
val myPreConfiguredClient = skrape(HttpFetcher) {
request {
timeout = 10_000
headers = mapOf("some-custom-header" to "some-value")
followRedirects = true
}
}
@Test
fun `can use preconfigured client straight away`() {
myPreConfiguredClient.response {
status { code toBe 200 }
headers.getValue("some-custom-header") toBe "some-value"
}
}
@Test
fun `can use preconfigured client but slightly modify`() {
myPreConfiguredClient.apply {
request {
followRedirects = false
}
}.response {
status { code toBe 301 }
headers.getValue("some-custom-header") toBe "some-value"
}
}Last updated
Was this helpful?