 (ns ring.core.protocols
   "Protocols necessary for Ring."
   {:added "1.6"}
+  (:import [java.io Writer OutputStream])
   (:require [clojure.java.io :as io]
             [ring.util.response :as response]))
 

      (doseq [chunk body]
        (.write writer (str chunk)))))
  java.io.InputStream
  (write-body-to-stream [body _ output-stream]
    (with-open [out output-stream, body body]
      (io/copy body out)))
  java.io.File
  (write-body-to-stream [body _ output-stream]
    (with-open [out output-stream]
      (io/copy body out)))
  nil

    "Write a value representing a response body to an output stream. The stream
    will be closed after the value had been written."))

(defn- ^Writer response-writer [response output-stream]
  (if-let [charset (response/get-charset response)]
    (io/writer output-stream :encoding charset)
    (io/writer output-stream)))
