Skip to content

vhqr0/clj-java-http

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Simple java.net.http wrapper for Clojure.

Example:

(require '[clj-java-http.core :as http])

(-> {:method :post
     :uri "https://example.com"
     :headers {"string-key" "single-val", :keyword-key ["1" :2 3]}
     :body "string-content"
     :as :string}
    ;; map => HttpResponse
    http/request
    ;; HttpResponse => map
    http/response->map
    (update :uri str)
    (update :headers http/headers->map))
;; =>>
{:uri "https://example.com"
 :staus 200
 :headers {"key-1" "val", "key-2" ["val-1" "val-2"]}
 :body "string-body"}

(-> {:method "put"
     :uri "https://example.com"
     :body (byte-array [1 2 3 4])
     :as :byte-array}
    http/request
    http/response->map)
;; =>>
{:body [1 2 3 4]}

Supported as keyword:

discard (default)
discard response body
string
return body as string
byte-array
return body as byte array
input-stream
return body as input stream

Supported body class:

nil
no request body
String
provide request body in string
bytes
provide request body in byte array
InputStream
provide request body in input stream

Other options:

version
supported version: http1.1 http2
redirect
supported redirect: normal never always
proxy
supported proxy: no-proxy
  • use jvm system properties by default (https?.proxy*)
timeout
timeout milliseconds

About

Simple java.net.http wrapper for Clojure.

Topics

Resources

Stars

Watchers

Forks

Contributors