       (transient {})
       (get-names headers))))
 
-(defn write-headers
+(defn ^:internal write-headers
   [output, headers]
   (doseq [[^String k, v] headers]
     (if (coll? v)

;; See the License for the specific language governing permissions and
;; limitations under the License.

(ns ^{:no-doc true}
  immutant.web.internal.headers
  (:require [clojure.string :as str]
            ring.util.request))

(def charset-pattern (deref #'ring.util.request/charset-pattern))

(def default-encoding "ISO-8859-1")

(defprotocol Headers
  (get-names [x])

  (set-header [x key value])
  (add-header [x key value]))

(defn ^:internal ^String get-character-encoding [headers]
  (or
    (when-let [type (get-value headers "content-type")]
      (second (re-find charset-pattern type)))
    default-encoding))

(defn ^:internal headers->map [headers]
  (persistent!
    (reduce
      (fn [accum ^String name]
