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

Quap

03/30/2023, 12:21 AM
Is there some set up required to make the ContentNegotiation plugin (Ktor Server) work correctly? I installed it without configuration and am using call.respond(file.readBytes()) to send the response, from a file. Content-Type header is not being set, it's the expected behavior. What am I doing wrong?
s

Sergey Shumov

03/30/2023, 6:16 AM
q

Quap

03/30/2023, 6:36 AM
@Sergey Shumov Thank you! It looks like I don't even need then content negotiation plugin installed for the correct Content-Type header to be set when using respondFile as you suggested. Do you have any opinion about using the content negotiation plugin? I do not need the serialization features, and the documentation is pretty sparse on what else it provides - if you have any insight there also, I would appreciate it - should I even install ContentNegotiation?
s

Sergey Shumov

03/30/2023, 6:42 AM
If you don't use JSON, XML, etc. formats for request and responses you don't need to install ContentNegotiation.
1
q

Quap

03/30/2023, 6:55 PM
Thanks again!
5 Views