Package com.linecorp.armeria.client
Interface WebClient
- All Superinterfaces:
ClientBuilderParams
,Unwrappable
An asynchronous web client.
-
Method Summary
Modifier and TypeMethodDescriptionblocking()
static WebClientBuilder
builder()
Returns a newWebClientBuilder
created without a baseURI
.static WebClientBuilder
builder
(SessionProtocol protocol, EndpointGroup endpointGroup) static WebClientBuilder
builder
(SessionProtocol protocol, EndpointGroup endpointGroup, String path) Returns a newWebClientBuilder
created with the specifiedSessionProtocol
, baseEndpointGroup
and path.static WebClientBuilder
Returns a newWebClientBuilder
created with the specified baseuri
.static WebClientBuilder
builder
(String protocol, EndpointGroup endpointGroup) static WebClientBuilder
builder
(String protocol, EndpointGroup endpointGroup, String path) Returns a newWebClientBuilder
created with the specifiedprotocol
.static WebClientBuilder
Returns a newWebClientBuilder
created with the specified baseURI
.default HttpResponse
Sends an HTTP DELETE request.default HttpResponse
delete
(String path, @Nullable QueryParams params) Sends an HTTP DELETE request, appending the given query parameters to the path.default HttpResponse
execute
(AggregatedHttpRequest aggregatedReq) Sends the specified HTTP request.default HttpResponse
execute
(HttpRequest req) Sends the specified HTTP request.execute
(HttpRequest req, RequestOptions options) Sends the specified HTTP request with the specifiedRequestOptions
.default HttpResponse
execute
(RequestHeaders headers) Sends an empty HTTP request with the specified headers.default HttpResponse
execute
(RequestHeaders headers, byte[] content) Sends an HTTP request with the specified headers and content.default HttpResponse
execute
(RequestHeaders headers, HttpData content) Sends an HTTP request with the specified headers and content.default HttpResponse
execute
(RequestHeaders headers, String content) Sends an HTTP request with the specified headers and content.default HttpResponse
execute
(RequestHeaders headers, String content, Charset charset) Sends an HTTP request with the specified headers and content.default HttpResponse
Sends an HTTP GET request.default HttpResponse
get
(String path, @Nullable QueryParams params) Sends an HTTP GET request, appending the given query parameters to the path.default HttpResponse
Sends an HTTP HEAD request.default HttpResponse
head
(String path, @Nullable QueryParams params) Sends an HTTP HEAD request, appending the given query parameters to the path.static WebClient
of()
Returns aWebClient
without a base URI using the defaultClientFactory
and the defaultClientOptions
.static WebClient
of
(SessionProtocol protocol, EndpointGroup endpointGroup) Returns a newWebClient
that connects to the specifiedEndpointGroup
with the specifiedSessionProtocol
using the defaultClientFactory
and the defaultClientOptions
.static WebClient
of
(SessionProtocol protocol, EndpointGroup endpointGroup, String path) Returns a newWebClient
that connects to the specifiedEndpointGroup
with the specifiedSessionProtocol
andpath
using the defaultClientFactory
and the defaultClientOptions
.static WebClient
Returns a newWebClient
that connects to the specifieduri
using the default options.static WebClient
of
(String protocol, EndpointGroup endpointGroup) Returns a newWebClient
that connects to the specifiedEndpointGroup
with the specifiedprotocol
using the defaultClientFactory
and the defaultClientOptions
.static WebClient
of
(String protocol, EndpointGroup endpointGroup, String path) Returns a newWebClient
that connects to the specifiedEndpointGroup
with the specifiedprotocol
andpath
using the defaultClientFactory
and the defaultClientOptions
.static WebClient
default HttpResponse
Sends an HTTP OPTIONS request.default HttpResponse
options
(String path, @Nullable QueryParams params) Sends an HTTP OPTIONS request, appending the given query parameters to the path.default HttpResponse
Sends an HTTP PATCH request with the specified content.default HttpResponse
patch
(String path, @Nullable QueryParams params, byte[] content) Sends an HTTP PATCH request with the specified content, appending the given query parameters to the path.default HttpResponse
patch
(String path, @Nullable QueryParams params, HttpData content) Sends an HTTP PATCH request with the specified content by appending the provided query params to the path.default HttpResponse
patch
(String path, @Nullable QueryParams params, String content) Sends an HTTP PATCH request with the specified content, appending the given query parameters to the path.default HttpResponse
Sends an HTTP PATCH request with the specified content, appending the given query parameters to the path.default HttpResponse
Sends an HTTP PATCH request with the specified content.default HttpResponse
Sends an HTTP PATCH request with the specified content.default HttpResponse
Sends an HTTP PATCH request with the specified content.default HttpResponse
Sends an HTTP POST request with the specified content.default HttpResponse
post
(String path, @Nullable QueryParams params, byte[] content) Sends an HTTP POST request with the specified content, appending the given query parameters to the path.default HttpResponse
post
(String path, @Nullable QueryParams params, HttpData content) Sends an HTTP POST request with the specified content, appending the given query parameters to the path.default HttpResponse
post
(String path, @Nullable QueryParams params, String content) Sends an HTTP POST request with the specified content, appending the given query parameters to the path.default HttpResponse
Sends an HTTP POST request with the specified content, appending the given query parameters to the path.default HttpResponse
Sends an HTTP POST request with the specified content.default HttpResponse
Sends an HTTP POST request with the specified content.default HttpResponse
Sends an HTTP POST request with the specified content.default WebClientRequestPreparation
prepare()
Prepares to send anHttpRequest
using fluent builder.default HttpResponse
Sends an HTTP PUT request with the specified content.default HttpResponse
put
(String path, @Nullable QueryParams params, byte[] content) Sends an HTTP PUT request with the specified content, appending the given query parameters to the path.default HttpResponse
put
(String path, @Nullable QueryParams params, HttpData content) Sends an HTTP PUT request with the specified content, appending the given query parameters to the path.default HttpResponse
put
(String path, @Nullable QueryParams params, String content) Sends an HTTP PUT request with the specified content, appending the given query parameters to the path.default HttpResponse
Sends an HTTP PUT request with the specified content, appending the given query parameters to the path.default HttpResponse
Sends an HTTP PUT request with the specified content.default HttpResponse
Sends an HTTP PUT request with the specified content.default HttpResponse
Sends an HTTP PUT request with the specified content.default HttpResponse
Sends an HTTP TRACE request.default HttpResponse
trace
(String path, @Nullable QueryParams params) Sends an HTTP TRACE request, appending the given query parameters to the path.unwrap()
Unwraps this object and returns the object being decorated.Methods inherited from interface com.linecorp.armeria.client.ClientBuilderParams
absolutePathRef, clientType, endpointGroup, options, scheme, uri
Methods inherited from interface com.linecorp.armeria.common.util.Unwrappable
as
-
Method Details
-
of
Returns aWebClient
without a base URI using the defaultClientFactory
and the defaultClientOptions
. -
of
Returns a newWebClient
that connects to the specifieduri
using the default options.- Parameters:
uri
- the URI of the server endpoint- Throws:
IllegalArgumentException
- if theuri
is not valid or its scheme is not one of the values inSessionProtocol.httpValues()
orSessionProtocol.httpsValues()
.
-
of
- Parameters:
uri
- theURI
of the server endpoint- Throws:
IllegalArgumentException
- if theuri
is not valid or its scheme is not one of the values inSessionProtocol.httpValues()
orSessionProtocol.httpsValues()
.
-
of
Returns a newWebClient
that connects to the specifiedEndpointGroup
with the specifiedprotocol
using the defaultClientFactory
and the defaultClientOptions
.- Parameters:
protocol
- the session protocol of theEndpointGroup
endpointGroup
- the serverEndpointGroup
- Throws:
IllegalArgumentException
- if theprotocol
is not one of the values inSessionProtocol.httpValues()
orSessionProtocol.httpsValues()
.
-
of
Returns a newWebClient
that connects to the specifiedEndpointGroup
with the specifiedSessionProtocol
using the defaultClientFactory
and the defaultClientOptions
.- Parameters:
protocol
- theSessionProtocol
of theEndpointGroup
endpointGroup
- the serverEndpointGroup
- Throws:
IllegalArgumentException
- if theprotocol
is not one of the values inSessionProtocol.httpValues()
orSessionProtocol.httpsValues()
.
-
of
Returns a newWebClient
that connects to the specifiedEndpointGroup
with the specifiedprotocol
andpath
using the defaultClientFactory
and the defaultClientOptions
.- Parameters:
protocol
- the session protocol of theEndpointGroup
endpointGroup
- the serverEndpointGroup
path
- the path to the endpoint- Throws:
IllegalArgumentException
- if theprotocol
is not one of the values inSessionProtocol.httpValues()
orSessionProtocol.httpsValues()
.
-
of
Returns a newWebClient
that connects to the specifiedEndpointGroup
with the specifiedSessionProtocol
andpath
using the defaultClientFactory
and the defaultClientOptions
.- Parameters:
protocol
- theSessionProtocol
of theEndpointGroup
endpointGroup
- the serverEndpointGroup
path
- the path to the endpoint- Throws:
IllegalArgumentException
- if theprotocol
is not one of the values inSessionProtocol.httpValues()
orSessionProtocol.httpsValues()
.
-
builder
Returns a newWebClientBuilder
created without a baseURI
. -
builder
Returns a newWebClientBuilder
created with the specified baseuri
.- Throws:
IllegalArgumentException
- if theuri
is not valid or its scheme is not one of the values inSessionProtocol.httpValues()
orSessionProtocol.httpsValues()
.
-
builder
Returns a newWebClientBuilder
created with the specified baseURI
.- Throws:
IllegalArgumentException
- if theuri
is not valid or its scheme is not one of the values inSessionProtocol.httpValues()
orSessionProtocol.httpsValues()
.
-
builder
- Throws:
IllegalArgumentException
- if theprotocol
is not one of the values inSessionProtocol.httpValues()
orSessionProtocol.httpsValues()
.
-
builder
- Throws:
IllegalArgumentException
- if theprotocol
is not one of the values inSessionProtocol.httpValues()
orSessionProtocol.httpsValues()
.
-
builder
- Throws:
IllegalArgumentException
- if theprotocol
is not one of the values inSessionProtocol.httpValues()
orSessionProtocol.httpsValues()
.
-
builder
Returns a newWebClientBuilder
created with the specifiedSessionProtocol
, baseEndpointGroup
and path.- Throws:
IllegalArgumentException
- if theprotocol
is not one of the values inSessionProtocol.httpValues()
orSessionProtocol.httpsValues()
.
-
execute
Sends the specified HTTP request. -
execute
Sends the specified HTTP request with the specifiedRequestOptions
. -
execute
Sends the specified HTTP request. -
execute
Sends an empty HTTP request with the specified headers. -
execute
Sends an HTTP request with the specified headers and content. -
execute
Sends an HTTP request with the specified headers and content. -
execute
Sends an HTTP request with the specified headers and content. -
execute
@CheckReturnValue default HttpResponse execute(RequestHeaders headers, String content, Charset charset) Sends an HTTP request with the specified headers and content. -
prepare
Prepares to send anHttpRequest
using fluent builder.WebClient client = WebClient.of(...); HttpResponse response = client.prepare() .post("/foo") .header(HttpHeaderNames.AUTHORIZATION, ...) .content(MediaType.JSON, ...) .execute();
-
options
Sends an HTTP OPTIONS request. -
options
Sends an HTTP OPTIONS request, appending the given query parameters to the path. -
get
Sends an HTTP GET request. -
get
Sends an HTTP GET request, appending the given query parameters to the path. -
head
Sends an HTTP HEAD request. -
head
Sends an HTTP HEAD request, appending the given query parameters to the path. -
post
Sends an HTTP POST request with the specified content. -
post
@CheckReturnValue default HttpResponse post(String path, @Nullable @Nullable QueryParams params, HttpData content) Sends an HTTP POST request with the specified content, appending the given query parameters to the path. -
post
Sends an HTTP POST request with the specified content. -
post
@CheckReturnValue default HttpResponse post(String path, @Nullable @Nullable QueryParams params, byte[] content) Sends an HTTP POST request with the specified content, appending the given query parameters to the path. -
post
Sends an HTTP POST request with the specified content. -
post
@CheckReturnValue default HttpResponse post(String path, @Nullable @Nullable QueryParams params, String content) Sends an HTTP POST request with the specified content, appending the given query parameters to the path. -
post
Sends an HTTP POST request with the specified content. -
post
@CheckReturnValue default HttpResponse post(String path, @Nullable @Nullable QueryParams params, String content, Charset charset) Sends an HTTP POST request with the specified content, appending the given query parameters to the path. -
put
Sends an HTTP PUT request with the specified content. -
put
@CheckReturnValue default HttpResponse put(String path, @Nullable @Nullable QueryParams params, HttpData content) Sends an HTTP PUT request with the specified content, appending the given query parameters to the path. -
put
Sends an HTTP PUT request with the specified content. -
put
@CheckReturnValue default HttpResponse put(String path, @Nullable @Nullable QueryParams params, byte[] content) Sends an HTTP PUT request with the specified content, appending the given query parameters to the path. -
put
Sends an HTTP PUT request with the specified content. -
put
@CheckReturnValue default HttpResponse put(String path, @Nullable @Nullable QueryParams params, String content) Sends an HTTP PUT request with the specified content, appending the given query parameters to the path. -
put
Sends an HTTP PUT request with the specified content. -
put
@CheckReturnValue default HttpResponse put(String path, @Nullable @Nullable QueryParams params, String content, Charset charset) Sends an HTTP PUT request with the specified content, appending the given query parameters to the path. -
patch
Sends an HTTP PATCH request with the specified content. -
patch
@CheckReturnValue default HttpResponse patch(String path, @Nullable @Nullable QueryParams params, HttpData content) Sends an HTTP PATCH request with the specified content by appending the provided query params to the path. -
patch
Sends an HTTP PATCH request with the specified content. -
patch
@CheckReturnValue default HttpResponse patch(String path, @Nullable @Nullable QueryParams params, byte[] content) Sends an HTTP PATCH request with the specified content, appending the given query parameters to the path. -
patch
Sends an HTTP PATCH request with the specified content. -
patch
@CheckReturnValue default HttpResponse patch(String path, @Nullable @Nullable QueryParams params, String content) Sends an HTTP PATCH request with the specified content, appending the given query parameters to the path. -
patch
Sends an HTTP PATCH request with the specified content. -
patch
@CheckReturnValue default HttpResponse patch(String path, @Nullable @Nullable QueryParams params, String content, Charset charset) Sends an HTTP PATCH request with the specified content, appending the given query parameters to the path. -
delete
Sends an HTTP DELETE request. -
delete
Sends an HTTP DELETE request, appending the given query parameters to the path. -
trace
Sends an HTTP TRACE request. -
trace
Sends an HTTP TRACE request, appending the given query parameters to the path. -
blocking
Returns aBlockingWebClient
that connects to the sameURI
with thisWebClient
.Note that you should never use the
BlockingWebClient
in anEventLoop
thread. Use it from a non-EventLoop
thread such asBlockingTaskExecutor
. -
unwrap
HttpClient unwrap()Description copied from interface:Unwrappable
Unwraps this object and returns the object being decorated. If thisUnwrappable
is the innermost object, this method returns itself. For example:class Foo implements Unwrappable {} class Bar<T extends Unwrappable> extends AbstractUnwrappable<T> { Bar(T delegate) { super(delegate); } } class Qux<T extends Unwrappable> extends AbstractUnwrappable<T> { Qux(T delegate) { super(delegate); } } Foo foo = new Foo(); assert foo.unwrap() == foo; Bar<Foo> bar = new Bar<>(foo); assert bar.unwrap() == foo; Qux<Bar<Foo>> qux = new Qux<>(bar); assert qux.unwrap() == bar; assert qux.unwrap().unwrap() == foo;
- Specified by:
unwrap
in interfaceUnwrappable
-