Liking cljdoc? Tell your friends :D

java-http-clj.core


build-clientclj

(build-client)
(build-client opts)

Builds a client with the supplied options. See HttpClient.Builder for a more detailed description of the options.

The opts map takes the following keys:

Equivalent to (.build (client-builder opts)).

Builds a client with the supplied options. See [HttpClient.Builder](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpClient.Builder.html) for a more detailed description of the options.

The `opts` map takes the following keys:

- `:connect-timeout` - connection timeout in milliseconds or a `java.time.Duration`
- `:cookie-handler` - a [java.net.CookieHandler](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/net/CookieHandler.html)
- `:executor` - a [java.util.concurrent.Executor](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/concurrent/Executor.html)
- `:follow-redirects` - one of `:always`, `:never` and `:normal`. Maps to the corresponding [HttpClient.Redirect](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpClient.Redirect.html) enum.
- `:priority` - the [priority](https://developers.google.com/web/fundamentals/performance/http2/#stream_prioritization) of the request (only used for HTTP/2 requests)
- `:proxy` - a [java.net.ProxySelector](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/net/ProxySelector.html)
- `:ssl-context` - a [javax.net.ssl.SSLContext](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/javax/net/ssl/SSLContext.html)
- `:ssl-parameters` - a [javax.net.ssl.SSLParameters](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/javax/net/ssl/SSLParameters.html)
- `:version` - the HTTP protocol version, one of `:http1.1` or `:http2`

Equivalent to `(.build (client-builder opts))`.
sourceraw docstring

build-requestclj

(build-request)
(build-request req-map)

Builds a java.net.http.HttpRequest from a map.

See send for a description of req-map.

Equivalent to (.build (request-builder req-map)).

Builds a [java.net.http.HttpRequest](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpRequest.html) from a map.

See [[send]] for a description of `req-map`.

Equivalent to `(.build (request-builder req-map))`.
sourceraw docstring

client-builderclj

(client-builder)
(client-builder opts)

Same as build-client, but returns a HttpClient.Builder instead of a HttpClient.

See build-client for a description of opts.

Same as [[build-client]], but returns a [HttpClient.Builder](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpClient.Builder.html) instead of a [HttpClient](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpClient.html).

See [[build-client]] for a description of `opts`.
sourceraw docstring

default-clientclj

Used for requests unless a client is explicitly passed. Equal to HttpClient.newHttpClient().

Used for requests unless a client is explicitly passed. Equal to [HttpClient.newHttpClient()](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpClient.html#newHttpClient%28%29).
sourceraw docstring

deleteclj

(delete uri)
(delete uri req-map)
(delete uri req-map opts)

Sends a DELETE request to uri.

See send for a description of req-map and opts.

Sends a DELETE request to `uri`.

See [[send]] for a description of `req-map` and `opts`.
sourceraw docstring

getclj

(get uri)
(get uri req-map)
(get uri req-map opts)

Sends a GET request to uri.

See send for a description of req-map and opts.

Sends a GET request to `uri`.

See [[send]] for a description of `req-map` and `opts`.
sourceraw docstring

(head uri)
(head uri req-map)
(head uri req-map opts)

Sends a HEAD request to uri.

See send for a description of req-map and opts.

Sends a HEAD request to `uri`.

See [[send]] for a description of `req-map` and `opts`.
sourceraw docstring

postclj

(post uri)
(post uri req-map)
(post uri req-map opts)

Sends a POST request to uri.

See send for a description of req-map and opts.

Sends a POST request to `uri`.

See [[send]] for a description of `req-map` and `opts`.
sourceraw docstring

putclj

(put uri)
(put uri req-map)
(put uri req-map opts)

Sends a PUT request to uri.

See send for a description of req-map and opts.

Sends a PUT request to `uri`.

See [[send]] for a description of `req-map` and `opts`.
sourceraw docstring

request-builderclj

(request-builder opts)

Same as build-request, but returns a HttpRequest.Builder instead of a HttpRequest.

Same as [[build-request]], but returns a [HttpRequest.Builder](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpRequest.Builder.html) instead of a [HttpRequest](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpRequest.html).
sourceraw docstring

response->mapclj

(response->map resp)

Converts a HttpResponse into a map.

The response map contains the following keys:

  • :body - the response body
  • :headers - the HTTP headers, a map where keys are strings and values are strings or a list of strings
  • :status - the HTTP status code
  • :version - the HTTP protocol version, one of :http1.1 or :http2
Converts a [HttpResponse](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpResponse.html) into a map.

The response map contains the following keys:

 - `:body` - the response body
 - `:headers` - the HTTP headers, a map where keys are strings and values are strings or a list of strings
 - `:status` - the HTTP status code
 - `:version` - the HTTP protocol version, one of `:http1.1` or `:http2`
sourceraw docstring

sendclj

(send req)
(send req {:keys [as client raw?] :as opts})

Sends a HTTP request and blocks until a response is returned or the request takes longer than the specified timeout. If the request times out, a HttpTimeoutException is thrown.

The req parameter can be a either string URL, a request map, or a java.net.http.HttpRequest.

The request map takes the following keys:

  • :body - the request body. Can be a string, a primitive Java byte array or a java.io.InputStream.
  • :expect-continue? - See the javadoc
  • :headers - the HTTP headers, a map where keys are strings and values are strings or a list of strings
  • :method - the HTTP method as a keyword (e.g :get, :put, :post)
  • :timeout - the request timeout in milliseconds or a java.time.Duration
  • :uri - the request uri
  • :version - the HTTP protocol version, one of :http1.1 or :http2

opts is a map containing one of the following keywords:

Sends a HTTP request and blocks until a response is returned or the request
takes longer than the specified `timeout`. If the request times out, a [HttpTimeoutException](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpTimeoutException.html)
is thrown.

The `req` parameter can be a either string URL, a request map, or a [java.net.http.HttpRequest](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpRequest.html).

The request map takes the following keys:

- `:body` - the request body. Can be a string, a primitive Java byte array or a java.io.InputStream.
- `:expect-continue?` - See the [javadoc](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpRequest.Builder.html#expectContinue%28boolean%29)
- `:headers` - the HTTP headers, a map where keys are strings and values are strings or a list of strings
- `:method` - the HTTP method as a keyword (e.g `:get`, `:put`, `:post`)
- `:timeout` - the request timeout in milliseconds or a `java.time.Duration`
- `:uri` - the request uri
- `:version` - the HTTP protocol version, one of `:http1.1` or `:http2`

`opts` is a map containing one of the following keywords:

- `:as` - converts the response body to one of the following formats:
    - `:string` - a java.lang.String (default)
    - `:byte-array` - a Java primitive byte array.
    - `:input-stream` - a java.io.InputStream.

- `:client` - the [HttpClient](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpClient.html) to use for the request. If not provided the [[default-client]] will be used.

- `:raw?` - if true, skip the Ring format conversion and return the [HttpResponse](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpResponse.html
sourceraw docstring

send-asyncclj

(send-async req)
(send-async req opts)
(send-async req {:keys [as client raw?] :as opts} callback ex-handler)

Sends a request asynchronously and immediately returns a CompletableFuture. Converts the eventual response to a map as per response->map.

See send for a description of req and opts.

callback is a one argument function that will be applied to the response on completion.

ex-handler is a one argument function that will be called if an exception is thrown anywhere during the request.

Sends a request asynchronously and immediately returns a [CompletableFuture](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletableFuture.html). Converts the
 eventual response to a map as per [[response->map]].

See [[send]] for a description of `req` and `opts`.

`callback` is a one argument function that will be applied to the response on completion.

`ex-handler` is a one argument function that will be called if an exception is thrown anywhere during the request.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close