12

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?

4

1 回答 1

6

是的,ring 确实关闭了在正文键中传递的 InputStream 对象。

签出:https ://github.com/mmcgrana/ring/blob/master/ring-servlet/src/ring/util/servlet.clj#L111

于 2013-01-13T15:58:38.407 回答