I wish to serve a PDF (or any other binary file) in a Clojure Ring response. This works
(defn serve-file [request]
{:status 200
:headers {"Content-Type" "application/pdf"}
:body (FileInputStream. "file.pdf")})
But I'm not explicitly closing the FileInputStream. Will this cause a memory leak, or is it closed by the underlying web server (Jetty). If not, how do I close it myself?
Yes, ring does close the InputStream object passed in body key.
Check out : https://github.com/mmcgrana/ring/blob/master/ring-servlet/src/ring/util/servlet.clj#L111
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With