Skip to content

Instantly share code, notes, and snippets.

@abedra
Created June 15, 2011 01:43
Show Gist options
  • Save abedra/1026329 to your computer and use it in GitHub Desktop.
Save abedra/1026329 to your computer and use it in GitHub Desktop.
Simple Clojure http get using Java's standard library
(import '(java.net URL URLEncoder)
(java.io BufferedReader InputStreamReader)))
(defn request [address]
(let [url (URL. address)]
(with-open [stream (. url (openStream))]
(let [buf (BufferedReader. (InputStreamReader. stream))]
(apply str (line-seq buf))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment