Created
June 15, 2011 01:43
-
-
Save abedra/1026329 to your computer and use it in GitHub Desktop.
Simple Clojure http get using Java's standard library
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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