Returns the HTTP response headers in order as a sequence of
[String,String] pairs. The first 'header' name may be null for the
HTTP status line.
(defn headers-seq
"Returns the HTTP response headers in order as a sequence of
[String,String] pairs. The first 'header' name may be null for the
HTTP status line."
[http-agnt]
(let [^HttpURLConnection conn (::connection @http-agnt)
f (fn thisfn [^Integer i]
;; Get value first because first key may be nil.
(when-let [value (.getHeaderField conn i)]
(cons [(.getHeaderFieldKey conn i) value]
(thisfn (inc i)))))]
(lazy-seq (f 0))))
Comments top
No comments for headers-seq. Log in to add a comment.