Last active
April 25, 2017 15:16
-
-
Save PetrGlad/243c64c707efdfdaa681d8c9929ec6bb to your computer and use it in GitHub Desktop.
Socket and connection parameters in clj-http
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
(require '[clj-http.client :as client] | |
'[clojure.java.io :as java.io] | |
'[clj-http.conn-mgr :as conn-mgr] | |
'[clojure.java.shell :as shell]) | |
(import org.apache.http.config.SocketConfig) | |
(import org.apache.http.config.ConnectionConfig) | |
(import java.io.InputStreamReader) | |
(import java.io.BufferedReader) | |
(def events-url "https://github.com") | |
(def token "asdfasdfasdfasdf") | |
(let [cm (conn-mgr/make-regular-conn-manager {})] | |
(.setSocketConfig cm | |
(-> (SocketConfig/copy (.getSocketConfig cm)) | |
(.setRcvBufSize 40) | |
(.build))) | |
(.setConnectionConfig cm | |
(-> (ConnectionConfig/copy (.getConnectionConfig cm)) | |
(.setBufferSize 40) | |
(.build))) | |
(prn ">") | |
(def ins (-> (client/get events-url | |
{:headers {"Authorization" (str "Bearer " token)} | |
:as :stream | |
:connection-manager cm}) | |
:body)) | |
(do #_clojure.core.async/thread | |
(doseq [l (-> ins | |
(InputStreamReader.) | |
(BufferedReader. 40) | |
line-seq)] | |
(prn l)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment