Package com.linecorp.armeria.client
Interface BlockingWebClient
- All Superinterfaces:
ClientBuilderParams
,Unwrappable
A blocking web client that waits for an
HttpResponse
to be fully aggregated.
If you want to create a BlockingWebClient
with various options, create a WebClient
first
and convert it into a BlockingWebClient
via WebClient.blocking()
.
BlockingWebClient client =
WebClient.builder("https://api.example.com")
.responseTimeout(Duration.ofSeconds(10))
.decorator(LoggingClient.newDecorator())
...
.build()
.blocking();
Note that you should never use this client in an EventLoop
thread.
Use it from a non-EventLoop
thread such as BlockingTaskExecutor
.
-
Method Summary
Modifier and TypeMethodDescriptiondefault AggregatedHttpResponse
Sends an HTTP DELETE request.default AggregatedHttpResponse
delete
(String path, @Nullable QueryParams params) Sends an HTTP DELETE request, appending the given query parameters to the path.default AggregatedHttpResponse
execute
(AggregatedHttpRequest aggregatedReq) Sends the specified HTTP request.default AggregatedHttpResponse
execute
(HttpRequest req) Sends the specified HTTP request.execute
(HttpRequest req, RequestOptions options) Sends the specified HTTP request with the specifiedRequestOptions
.default AggregatedHttpResponse
execute
(RequestHeaders headers) Sends an empty HTTP request with the specified headers.default AggregatedHttpResponse
execute
(RequestHeaders headers, byte[] content) Sends an HTTP request with the specified headers and content.default AggregatedHttpResponse
execute
(RequestHeaders headers, HttpData content) Sends an HTTP request with the specified headers and content.default AggregatedHttpResponse
execute
(RequestHeaders headers, String content) Sends an HTTP request with the specified headers and content.default AggregatedHttpResponse
execute
(RequestHeaders headers, String content, Charset charset) Sends an HTTP request with the specified headers and content.default AggregatedHttpResponse
Sends an HTTP GET request.default AggregatedHttpResponse
get
(String path, @Nullable QueryParams params) Sends an HTTP GET request, appending the given query parameters to the path.default AggregatedHttpResponse
Sends an HTTP HEAD request.default AggregatedHttpResponse
head
(String path, @Nullable QueryParams params) Sends an HTTP HEAD request, appending the given query parameters to the path.static BlockingWebClient
of()
Returns aBlockingWebClient
without a base URI using the defaultClientFactory
and the defaultClientOptions
.static BlockingWebClient
Returns a newBlockingWebClient
that connects to the specifieduri
using the default options.static BlockingWebClient
Returns a newBlockingWebClient
that connects to the specifiedURI
using the default options.default AggregatedHttpResponse
Sends an HTTP OPTIONS request.default AggregatedHttpResponse
options
(String path, @Nullable QueryParams params) Sends an HTTP OPTIONS request, appending the given query parameters to the path.default AggregatedHttpResponse
Sends an HTTP PATCH request with the specified content.default AggregatedHttpResponse
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 AggregatedHttpResponse
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 AggregatedHttpResponse
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 AggregatedHttpResponse
Sends an HTTP PATCH request with the specified content, appending the given query parameters to the path.default AggregatedHttpResponse
Sends an HTTP PATCH request with the specified content.default AggregatedHttpResponse
Sends an HTTP PATCH request with the specified content.default AggregatedHttpResponse
Sends an HTTP PATCH request with the specified content.default AggregatedHttpResponse
Sends an HTTP POST request with the specified content.default AggregatedHttpResponse
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 AggregatedHttpResponse
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 AggregatedHttpResponse
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 AggregatedHttpResponse
Sends an HTTP POST request with the specified content, appending the given query parameters to the path.default AggregatedHttpResponse
Sends an HTTP POST request with the specified content.default AggregatedHttpResponse
Sends an HTTP POST request with the specified content.default AggregatedHttpResponse
Sends an HTTP POST request with the specified content.prepare()
Prepares to send anHttpRequest
using fluent builder.default AggregatedHttpResponse
Sends an HTTP PUT request with the specified content.default AggregatedHttpResponse
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 AggregatedHttpResponse
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 AggregatedHttpResponse
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 AggregatedHttpResponse
Sends an HTTP PUT request with the specified content, appending the given query parameters to the path.default AggregatedHttpResponse
Sends an HTTP PUT request with the specified content.default AggregatedHttpResponse
Sends an HTTP PUT request with the specified content.default AggregatedHttpResponse
Sends an HTTP PUT request with the specified content.default AggregatedHttpResponse
Sends an HTTP TRACE request.default AggregatedHttpResponse
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, equalsIgnoreWrapper, unwrapAll
-
Method Details
-
of
Returns aBlockingWebClient
without a base URI using the defaultClientFactory
and the defaultClientOptions
. -
of
Returns a newBlockingWebClient
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
Returns a newBlockingWebClient
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()
.
-
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
Sends an HTTP request with the specified headers and content. -
prepare
BlockingWebClientRequestPreparation prepare()Prepares to send anHttpRequest
using fluent builder.WebClient webClient = WebClient.of(...); BlockingWebClient client = webClient.blocking(); AggregatedHttpResponse 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
default AggregatedHttpResponse 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
default AggregatedHttpResponse 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
default AggregatedHttpResponse 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
default AggregatedHttpResponse 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
default AggregatedHttpResponse 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
default AggregatedHttpResponse 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
default AggregatedHttpResponse 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
default AggregatedHttpResponse 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
default AggregatedHttpResponse 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
default AggregatedHttpResponse 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
default AggregatedHttpResponse 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
default AggregatedHttpResponse 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. -
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
-