Hi, I need some help. I'm using ktor server to bui...
# ktor
j
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
did you try Route.static()?
this is how im serving images
j
The images i'm serving are dynamicaly fetched or buid internaly, so they are not static assets.
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" !!!