Liking cljdoc? Tell your friends :D

dgknght.tasks.http

Send HTTP requests, following redirects for any method.

A successful request returns a map of the response's :url (the one it finally came from, after redirects), :headers and :body. Anything else throws an ex-info whose data has the request's :url and a :type of:

::unreachable The server couldn't be reached ::unauthorized The server rejected the credentials (401) ::not-found Nothing is at the URL (404, 410) ::method-not-allowed The resource doesn't support the method (405) ::precondition-failed A conditional header didn't match (412) ::unexpected-response The server responded with something else

Except for ::unreachable, the data also has the response's :status and :body.

A request that can't connect within its connection timeout, or whose response stops arriving for longer than its socket timeout, fails as ::unreachable rather than waiting forever. A read-only request (GET, HEAD, OPTIONS, PROPFIND or REPORT) that stalls, or whose connection is reset or closed, is tried once more first. Other requests aren't, since the server may have applied them already.

Requests given a connection-pool reuse its connections rather than opening (and, for HTTPS, handshaking) a new one each time.

Each request sent, including each redirect followed, is logged at DEBUG with its method, URL, status and duration, but not its headers or body. Credentials are never logged.

Credentials go out with HTTP Basic authentication unless the server answers with a Digest challenge, in which case the request is sent again with Digest authentication, which is then used from the start for later requests to the same server.

Send HTTP requests, following redirects for any method.

A successful request returns a map of the response's :url (the one it
finally came from, after redirects), :headers and :body. Anything else
throws an ex-info whose data has the request's :url and a :type of:

  ::unreachable          The server couldn't be reached
  ::unauthorized         The server rejected the credentials (401)
  ::not-found            Nothing is at the URL (404, 410)
  ::method-not-allowed   The resource doesn't support the method (405)
  ::precondition-failed  A conditional header didn't match (412)
  ::unexpected-response  The server responded with something else

Except for ::unreachable, the data also has the response's :status and
:body.

A request that can't connect within its connection timeout, or whose
response stops arriving for longer than its socket timeout, fails as
::unreachable rather than waiting forever. A read-only request (GET, HEAD,
OPTIONS, PROPFIND or REPORT) that stalls, or whose connection is reset or
closed, is tried once more first. Other requests aren't, since the server
may have applied them already.

Requests given a `connection-pool` reuse its connections rather than
opening (and, for HTTPS, handshaking) a new one each time.

Each request sent, including each redirect followed, is logged at DEBUG
with its method, URL, status and duration, but not its headers or body.
Credentials are never logged.

Credentials go out with HTTP Basic authentication unless the server
answers with a Digest challenge, in which case the request is sent again
with Digest authentication, which is then used from the start for later
requests to the same server.
raw docstring

close-poolclj

(close-pool pool)

Closes the pool's connections.

Closes the pool's connections.
raw docstring

connection-poolclj

(connection-pool opts)

Creates a pool of connections for requests given it as their :connection-pool option to share. Its connections time out as the options' :connection-timeout and :socket-timeout (see request) say, including while an HTTPS connection's TLS handshake is under way. Release it with close-pool.

Creates a pool of connections for requests given it as their
:connection-pool option to share. Its connections time out as the options'
:connection-timeout and :socket-timeout (see `request`) say, including
while an HTTPS connection's TLS handshake is under way. Release it with
`close-pool`.
raw docstring

requestclj

(request req {:keys [connection-pool] :as opts})

Sends the clj-http request and returns the response if it succeeded. Options include: :username Identifies the user making the request :password Proves the identity of the user :multistatus? Indicates the request expects multiple parts possibly with different statuses :throw-on-no-content? Indicates that a successful response without content is an exception :throw-if-not-committed? Indicates a 202 status is an exception :connection-timeout Milliseconds to wait to connect (default 10000) :socket-timeout Milliseconds to wait for each part of the response (default 15000) :connection-pool A pool from connection-pool whose connections the request reuses

Sends the clj-http request and returns the response if it succeeded.
Options include:
  :username     Identifies the user making the request
  :password     Proves the identity of the user
  :multistatus? Indicates the request expects multiple parts possibly with
                different statuses
  :throw-on-no-content? Indicates that a successful response without content
                        is an exception
  :throw-if-not-committed? Indicates a 202 status is an exception
  :connection-timeout Milliseconds to wait to connect (default 10000)
  :socket-timeout Milliseconds to wait for each part of the response
                  (default 15000)
  :connection-pool A pool from `connection-pool` whose connections the
                   request reuses
raw docstring

resolve-urlclj

(resolve-url base href)

Resolves the href, which may be relative, against the base URL.

Resolves the href, which may be relative, against the base URL.
raw docstring

successful-status-line?clj

(successful-status-line? line)

Whether the status line, e.g. "HTTP/1.1 200 OK" as found in a WebDAV multistatus, reports success.

Whether the status line, e.g. "HTTP/1.1 200 OK" as found in a WebDAV
multistatus, reports success.
raw 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