Hi, I need some help.
I'm using ktor server to build a REST server.
I'm using jackson ContentNegotiation and everything is fine.
Except now I want that some of my routes answer sometime an image.
But event I'm setting the ContentType in my response (call.respondBytes(resultFile.readBytes(), ContentType("image", "png"))) I see that actual headers are still "application/json" ...
How can I tweak ktor to not override contentType when I'm explicitly setting it in my response ?
j
Jorge R
10/16/2019, 4:40 PM
did you try Route.static()?
Jorge R
10/16/2019, 4:40 PM
this is how im serving images
j
jfburdet
10/16/2019, 5:00 PM
The images i'm serving are dynamicaly fetched or buid internaly, so they are not static assets.
jfburdet
10/16/2019, 5:58 PM
Hmm, that's weird, it seems that I misinterpreted the problem.
The cause of my problem could be the following : answering http 304 with json auto-negotiation can lead to something weird :
call.respond(HttpStatusCode.NotModified, message = "") will make a correct 304 response.
BUT
call.respond(HttpStatusCode.NotModified) will return a json document containing "304" !!!