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.
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. 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.
(request req 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 60000)
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 60000)(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.
(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.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |