I'm doing `call.response.contentType(ContentType.A...
# ktor
r
I'm doing
call.response.contentType(ContentType.Application.Json.withCharset(Charsets.UTF_8))
as per https://ktor.io/servers/responses.html#properties, but get the Exception
io.ktor.response.UnsafeHeaderException: Header Content-Type is controlled by the engine and cannot be set explicitly
. How can I send JSON? I don't have
ContentNegotiation
installed, and don't want it.
📝 1
c
You have to send an object that have content type
d
call.respondText
, you can set the contentType as an optional argument of that method.
c
as far as response object could be transformed, it is important to not set content type globally
d
I’m going to remove that from the documentation
c
Btw, it's serious: we have to deprecate
contentType
extension function
1
r
Thanks guys
c
Done. @Deactivated User Not sure how can we make attention on this deprecation before release
Perhaps, add to migration steps?
d
Probably nobody is using it because it doesn’t work (because of the exception), so I guess we can just remove it in 0.9.4? What do you think? I will update the documentation to no reference it. In the meantime I’m going to put that there are those methods, but that they doesn’t work but throw an exception and how to do it properly