Is there a possibility to cancel a respondOutputSt...
# ktor
p
Is there a possibility to cancel a respondOutputStream call in case an error occurs during writing to the outputstream and respond with a specified http status code? Currently the request just gives me an empty response but with sucess status 200
Copy code
call.respondOutputStream { 
     fileHandler.download(this)
}
I could only find following question on stackoverflow: https://stackoverflow.com/questions/69408466/how-to-propagate-error-in-outputstream-to-client-when-using-ktor
j
I’m not sure there’s anything that can be done if you’ve already already started writing (200 OK already sent and perhaps first body bytes sent), but you may be able to defer opening the output stream until you’ve verified what you need to.
p
That's my current solution for the problem. Doing the fileprocessing first and if that is successful then writing to the outputstream. This allows to separate successful and error case.