Is it possible to override response headers? I’m r...
# ktor
k
Is it possible to override response headers? I’m requesting a resource that is a JSON file, but it is in the text file and response
Content-Type
header is
application/octet-stream
. That is why when I’m requesting this resource, I’m getting
No transformation found
exception, because Json serializer doesn’t know it should parse this file. When I tell serializer to handle also this content type it works properly:
Copy code
install(JsonFeature) {
    serializer = serializerProvider.get()
    accept(ContentType.Application.Json, ContentType.Application.OctetStream)
}
but it fell a little bit hacky to do it for all requests Is there a better solution? (of course the best it would be to fix it on the API side, but I don’t have an access to it)
a
The accept function seems the most appropriate for me. Otherwise you could interrupt the request by installing a custom feature to change the header, checkout this.
k
Good idea, thanks. This way I could limit this solution to only the endpoint I know needs this