HttpClient Interface

public interface HttpClient

A generic interface for sending HTTP requests and getting responses.

Method Summary

Modifier and Type Method and Description
static HttpClient createDefault()

Creates a new HttpClient instance.

static HttpClient createDefault(HttpClientOptions clientOptions)

Creates a new HttpClient instance.

abstract Mono<HttpResponse> send(HttpRequest request)

Send the provided request asynchronously.

default Mono<HttpResponse> send(HttpRequest request, Context context)

Sends the provided request asynchronously with contextual information.

default HttpResponse sendSync(HttpRequest request, Context context)

Sends the provided request synchronously with contextual information.

Method Details

createDefault

public static HttpClient createDefault()

Creates a new HttpClient instance.

Returns:

A new HttpClient instance.

createDefault

public static HttpClient createDefault(HttpClientOptions clientOptions)

Creates a new HttpClient instance.

Parameters:

clientOptions - Configuration options applied to the created HttpClient.

Returns:

A new HttpClient instance.

send

public abstract Mono send(HttpRequest request)

Send the provided request asynchronously.

Parameters:

request - The HTTP request to send.

Returns:

A Mono that emits the response asynchronously.

send

public default Mono send(HttpRequest request, Context context)

Sends the provided request asynchronously with contextual information.

Parameters:

request - The HTTP request to send.
context - Contextual information about the request.

Returns:

A Mono that emits the response asynchronously.

sendSync

public default HttpResponse sendSync(HttpRequest request, Context context)

Sends the provided request synchronously with contextual information.

Parameters:

request - The HTTP request to send.
context - Contextual information about the request.

Returns:

The response.

Applies to