Liking cljdoc? Tell your friends :D

koine.http

Outbound HTTP, portable. One request shape, one response shape, every host.

Outbound HTTP, portable. One request shape, one response shape, every host.
raw docstring

failed?clj/s

(failed? res)

True when res is a TRANSPORT failure rather than an HTTP response.

A 404 or a 500 is not a failure — it is an answer, and :status carries it.

True when `res` is a TRANSPORT failure rather than an HTTP response.

A 404 or a 500 is not a failure — it is an answer, and `:status` carries it.
sourceraw docstring

(header res k)

Look up one response header, case-insensitively. res is a response map.

(header res "Mcp-Session-Id") works on every host and whatever case the server chose.

Look up one response header, case-insensitively. `res` is a response map.

`(header res "Mcp-Session-Id")` works on every host and whatever case the
server chose.
sourceraw docstring

normalize-headersclj/s

(normalize-headers headers)

Response headers with every name lowercased. Idempotent; nil-tolerant.

Nil-tolerant on purpose — cljgo's AOT discovery pass substitutes nil for host results, so a nil-intolerant function on this path fails at BUILD time.

Response headers with every name lowercased. Idempotent; nil-tolerant.

Nil-tolerant on purpose — cljgo's AOT discovery pass substitutes nil for host
results, so a nil-intolerant function on this path fails at BUILD time.
sourceraw docstring

post-jsonclj/s

(post-json url headers json-body)

POST a pre-encoded JSON string. Convenience over request.

POST a pre-encoded JSON string. Convenience over `request`.
sourceraw docstring

requestclj/s

(request req)

Perform an HTTP request.

req: {:method :post :url "…" :headers {"k" "v"} :body "…" :timeout-ms 30000} -> {:status 200 :headers {…} :body "…"}

NEVER throws on a transport failure. It returns one:

-> {:status nil :error :timeout | :dns | :connect-failed | :transport :error-message "…" :url "…"}

A retry policy has to branch on which failure it was, and no portable catch can tell them apart — see the comment above. failed? is the predicate; a non-2xx status is NOT a failure and arrives with :status set as usual.

Header values are passed through verbatim and never logged — they routinely carry credentials.

Perform an HTTP request.

req: {:method :post :url "…" :headers {"k" "v"} :body "…" :timeout-ms 30000}
->   {:status 200 :headers {…} :body "…"}

NEVER throws on a transport failure. It returns one:

->   {:status nil :error :timeout | :dns | :connect-failed | :transport
      :error-message "…" :url "…"}

A retry policy has to branch on which failure it was, and no portable `catch`
can tell them apart — see the comment above. `failed?` is the predicate; a
non-2xx status is NOT a failure and arrives with `:status` set as usual.

Header values are passed through verbatim and never logged — they routinely
carry credentials.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close