Package com.linecorp.armeria.client
Interface WebClient
- All Superinterfaces:
ClientBuilderParams
,Unwrappable
public interface WebClient extends ClientBuilderParams, Unwrappable
An asynchronous web client.
-
Method Summary
Modifier and Type Method Description 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
builder(String uri)
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
builder(URI uri)
Returns a newWebClientBuilder
created with the specified baseURI
.default HttpResponse
delete(String path)
Sends an HTTP DELETE request.HttpResponse
execute(AggregatedHttpRequest aggregatedReq)
Sends the specified HTTP request.HttpResponse
execute(HttpRequest req)
Sends the specified HTTP request.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
get(String path)
Sends an HTTP GET request.default HttpResponse
head(String path)
Sends an HTTP HEAD request.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
of(String uri)
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
of(URI uri)
default HttpResponse
options(String path)
Sends an HTTP OPTIONS request.default HttpResponse
patch(String path, byte[] content)
Sends an HTTP PATCH request with the specified content.default HttpResponse
patch(String path, HttpData content)
Sends an HTTP PATCH request with the specified content.default HttpResponse
patch(String path, String content)
Sends an HTTP PATCH request with the specified content.default HttpResponse
patch(String path, String content, Charset charset)
Sends an HTTP PATCH request with the specified content.default HttpResponse
post(String path, byte[] content)
Sends an HTTP POST request with the specified content.default HttpResponse
post(String path, HttpData content)
Sends an HTTP POST request with the specified content.default HttpResponse
post(String path, String content)
Sends an HTTP POST request with the specified content.default HttpResponse
post(String path, String content, Charset charset)
Sends an HTTP POST request with the specified content.default WebClientRequestPreparation
prepare()
Prepares to send anHttpRequest
using fluent builder.default HttpResponse
put(String path, byte[] content)
Sends an HTTP PUT request with the specified content.default HttpResponse
put(String path, HttpData content)
Sends an HTTP PUT request with the specified content.default HttpResponse
put(String path, String content)
Sends an HTTP PUT request with the specified content.default HttpResponse
put(String path, String content, Charset charset)
Sends an HTTP PUT request with the specified content.default HttpResponse
trace(String path)
Sends an HTTP TRACE request.HttpClient
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
-
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
static WebClientBuilder builder(SessionProtocol protocol, EndpointGroup endpointGroup, String path)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. -
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. -
get
Sends an HTTP GET request. -
head
Sends an HTTP HEAD request. -
post
Sends an HTTP POST request with the specified content. -
post
Sends an HTTP POST request with the specified content. -
post
Sends an HTTP POST request with the specified content. -
post
Sends an HTTP POST request with the specified content. -
put
Sends an HTTP PUT request with the specified content. -
put
Sends an HTTP PUT request with the specified content. -
put
Sends an HTTP PUT request with the specified content. -
put
Sends an HTTP PUT request with the specified content. -
patch
Sends an HTTP PATCH request with the specified content. -
patch
Sends an HTTP PATCH request with the specified content. -
patch
Sends an HTTP PATCH request with the specified content. -
patch
Sends an HTTP PATCH request with the specified content. -
delete
Sends an HTTP DELETE request. -
trace
Sends an HTTP TRACE request. -
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
-