https://kotlinlang.org logo
#ktor
Title
# ktor
d

Daniel

03/21/2023, 1:08 PM
Is there a ktor-client plugin that adds set of default headers such as Date (counterpart to server plugin DefaultHeaders)?
c

CLOVIS

03/21/2023, 1:09 PM
d

Daniel

03/21/2023, 1:12 PM
I found that, but there doesnt seem to be option to add Date header?
b

Berkay Özkan

03/21/2023, 1:18 PM
Copy code
defaultRequest {
    header("X-Date", "${Instant.now()}")
}
You can use something like this. Or are you looking for something else?
d

Daniel

03/21/2023, 1:21 PM
I wanted standard Date header, I thought the client would add one by default https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Date
Ok, I solved it by
Copy code
defaultRequest{
    header(HttpHeaders.Date, GMTDate().toHttpDate())
}
6 Views