cljs.repl.browser/send-and-close
function | removed v0.0-1503 | added v0.0-927 | Edit |
(send-and-close conn status form)
(send-and-close conn status form content-type)
Source docstring:
Use the passed connection to send a form to the browser. Send a
proper HTTP response.
(defn send-and-close
([conn status form]
(send-and-close conn status form "text/html"))
([conn status form content-type]
(let [utf-8-form (.getBytes form "UTF-8")
content-length (count utf-8-form)
headers (map #(.getBytes (str % "\r\n"))
[(status-line status)
"Server: ClojureScript REPL"
(str "Content-Type: "
content-type
"; charset=utf-8")
(str "Content-Length: " content-length)
""])]
(with-open [os (.getOutputStream conn)]
(do (doseq [header headers]
(.write os header 0 (count header)))
(.write os utf-8-form 0 content-length)
(.flush os)
(.close conn))))))