Class HttpRequest<T>
- java.lang.Object
-
- io.vertx.mutiny.ext.web.client.HttpRequest<T>
-
public class HttpRequest<T> extends Object
A client-side HTTP request.Instances are created by an
WebClient
instance, via one of the methods corresponding to the specific HTTP methods such asWebClient.get(java.lang.String)
, etc...The request shall be configured prior sending, the request is immutable and when a mutator method is called, a new request is returned allowing to expose the request in a public API and apply further customization.
After the request has been configured, the methods
send()
sendStream(io.vertx.mutiny.core.streams.ReadStream<io.vertx.mutiny.core.buffer.Buffer>)
sendJson(java.lang.Object)
()}sendForm(io.vertx.mutiny.core.MultiMap)
sendXXX
methods perform the actual request, they can be called multiple times to perform the same HTTP request at different points in time.The handler is called back with
- an
HttpResponse
instance when the HTTP response has been received - a failure when the HTTP request failed (like a connection error) or when the HTTP response could not be obtained (like connection or unmarshalling errors)
Most of the time, this client will buffer the HTTP response fully unless a specific is used such as .
NOTE: This class has been automatically generated from theoriginal
non Mutiny-ified interface using Vert.x codegen.
-
-
Field Summary
Fields Modifier and Type Field Description static TypeArg<HttpRequest>
__TYPE_ARG
TypeArg<T>
__typeArg_0
-
Constructor Summary
Constructors Constructor Description HttpRequest(io.vertx.ext.web.client.HttpRequest delegate)
HttpRequest(io.vertx.ext.web.client.HttpRequest delegate, TypeArg<T> typeArg_0)
HttpRequest(Object delegate, TypeArg<T> typeArg_0)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description HttpRequest<T>
addQueryParam(String paramName, String paramValue)
<U> HttpRequest<U>
as(BodyCodec<U> responseCodec)
HttpRequest<T>
authentication(io.vertx.ext.auth.authentication.Credentials credentials)
HttpRequest<T>
basicAuthentication(Buffer id, Buffer password)
HttpRequest<T>
basicAuthentication(String id, String password)
HttpRequest<T>
bearerTokenAuthentication(String bearerToken)
HttpRequest<T>
copy()
boolean
equals(Object o)
HttpRequest<T>
expect(ResponsePredicate predicate)
HttpRequest<T>
expect(Function<HttpResponse<Void>,ResponsePredicateResult> predicate)
HttpRequest<T>
followRedirects(boolean value)
io.vertx.ext.web.client.HttpRequest
getDelegate()
int
hashCode()
MultiMap
headers()
HttpRequest<T>
host(String value)
HttpRequest<T>
method(io.vertx.core.http.HttpMethod value)
HttpRequest<T>
multipartMixed(boolean allow)
static <T> HttpRequest<T>
newInstance(io.vertx.ext.web.client.HttpRequest arg)
static <T> HttpRequest<T>
newInstance(io.vertx.ext.web.client.HttpRequest arg, TypeArg<T> __typeArg_T)
HttpRequest<T>
port(int value)
HttpRequest<T>
putHeader(String name, Iterable<String> value)
HttpRequest<T>
putHeader(String name, String value)
HttpRequest<T>
putHeaders(MultiMap headers)
MultiMap
queryParams()
io.smallrye.mutiny.Uni<HttpResponse<T>>
send()
Send a request, thehandler
will receive the response as anHttpResponse
.HttpResponse<T>
sendAndAwait()
Blocking variant ofsend()
.void
sendAndForget()
Variant ofsend()
that ignores the result of the operation.io.smallrye.mutiny.Uni<HttpResponse<T>>
sendBuffer(Buffer body)
Likesend()
but with an HTTP requestbody
buffer.HttpResponse<T>
sendBufferAndAwait(Buffer body)
Blocking variant ofsendBuffer(io.vertx.mutiny.core.buffer.Buffer)
.void
sendBufferAndForget(Buffer body)
Variant ofsendBuffer(io.vertx.mutiny.core.buffer.Buffer)
that ignores the result of the operation.io.smallrye.mutiny.Uni<HttpResponse<T>>
sendForm(MultiMap body)
Likesend()
but with an HTTP requestbody
multimap encoded as form and the content type set toapplication/x-www-form-urlencoded
.io.smallrye.mutiny.Uni<HttpResponse<T>>
sendForm(MultiMap body, String charset)
Likesend()
but with an HTTP requestbody
multimap encoded as form and the content type set toapplication/x-www-form-urlencoded
.HttpResponse<T>
sendFormAndAwait(MultiMap body)
Blocking variant ofsendForm(io.vertx.mutiny.core.MultiMap)
.HttpResponse<T>
sendFormAndAwait(MultiMap body, String charset)
Blocking variant ofsendForm(io.vertx.mutiny.core.MultiMap,String)
.void
sendFormAndForget(MultiMap body)
Variant ofsendForm(io.vertx.mutiny.core.MultiMap)
that ignores the result of the operation.void
sendFormAndForget(MultiMap body, String charset)
Variant ofsendForm(io.vertx.mutiny.core.MultiMap,String)
that ignores the result of the operation.io.smallrye.mutiny.Uni<HttpResponse<T>>
sendJson(Object body)
Likesend()
but with an HTTP requestbody
object encoded as json and the content type set toapplication/json
.HttpResponse<T>
sendJsonAndAwait(Object body)
Blocking variant ofsendJson(Object)
.void
sendJsonAndForget(Object body)
Variant ofsendJson(Object)
that ignores the result of the operation.io.smallrye.mutiny.Uni<HttpResponse<T>>
sendJsonObject(io.vertx.core.json.JsonObject body)
Likesend()
but with an HTTP requestbody
object encoded as json and the content type set toapplication/json
.HttpResponse<T>
sendJsonObjectAndAwait(io.vertx.core.json.JsonObject body)
Blocking variant ofsendJsonObject(JsonObject)
.void
sendJsonObjectAndForget(io.vertx.core.json.JsonObject body)
Variant ofsendJsonObject(JsonObject)
that ignores the result of the operation.io.smallrye.mutiny.Uni<HttpResponse<T>>
sendMultipartForm(MultipartForm body)
Likesend()
but with an HTTP requestbody
multimap encoded as form and the content type set tomultipart/form-data
.HttpResponse<T>
sendMultipartFormAndAwait(MultipartForm body)
Blocking variant ofsendMultipartForm(io.vertx.mutiny.ext.web.multipart.MultipartForm)
.void
sendMultipartFormAndForget(MultipartForm body)
Variant ofsendMultipartForm(io.vertx.mutiny.ext.web.multipart.MultipartForm)
that ignores the result of the operation.io.smallrye.mutiny.Uni<HttpResponse<T>>
sendStream(ReadStream<Buffer> body)
Likesend()
but with an HTTP requestbody
stream.io.smallrye.mutiny.Uni<HttpResponse<T>>
sendStream(org.reactivestreams.Publisher<Buffer> body)
Likesend()
but with an HTTP requestbody
stream.HttpResponse<T>
sendStreamAndAwait(ReadStream<Buffer> body)
Blocking variant ofio.vertx.mutiny.ext.web.client.HttpRequest#sendStream(io.vertx.mutiny.core.streams.ReadStream
.) HttpResponse<T>
sendStreamAndAwait(org.reactivestreams.Publisher<Buffer> body)
Blocking variant ofsendStream(Publisher<Buffer>)
.void
sendStreamAndForget(ReadStream<Buffer> body)
Variant ofio.vertx.mutiny.ext.web.client.HttpRequest#sendStream(io.vertx.mutiny.core.streams.ReadStream
that ignores the result of the operation.) void
sendStreamAndForget(org.reactivestreams.Publisher<Buffer> body)
Variant ofsendStream(Publisher<Buffer>)
that ignores the result of the operation.HttpRequest<T>
setQueryParam(String paramName, String paramValue)
HttpRequest<T>
ssl(Boolean value)
HttpRequest<T>
timeout(long value)
String
toString()
HttpRequest<T>
uri(String value)
HttpRequest<T>
virtualHost(String value)
-
-
-
Field Detail
-
__TYPE_ARG
public static final TypeArg<HttpRequest> __TYPE_ARG
-
-
Method Detail
-
getDelegate
public io.vertx.ext.web.client.HttpRequest getDelegate()
-
method
public HttpRequest<T> method(io.vertx.core.http.HttpMethod value)
- Parameters:
value
-- Returns:
- a reference to this, so the API can be used fluently
-
port
public HttpRequest<T> port(int value)
- Parameters:
value
-- Returns:
- a reference to this, so the API can be used fluently
-
as
public <U> HttpRequest<U> as(BodyCodec<U> responseCodec)
- Parameters:
responseCodec
- the response codec- Returns:
- a reference to this, so the API can be used fluently
-
host
public HttpRequest<T> host(String value)
- Parameters:
value
-- Returns:
- a reference to this, so the API can be used fluently
-
virtualHost
public HttpRequest<T> virtualHost(String value)
- Parameters:
value
-- Returns:
- a reference to this, so the API can be used fluently
-
uri
public HttpRequest<T> uri(String value)
- Parameters:
value
-- Returns:
- a reference to this, so the API can be used fluently
-
putHeaders
public HttpRequest<T> putHeaders(MultiMap headers)
- Parameters:
headers
- The HTTP headers- Returns:
- a reference to this, so the API can be used fluently
-
putHeader
public HttpRequest<T> putHeader(String name, String value)
- Parameters:
name
- the header namevalue
- the header value- Returns:
- a reference to this, so the API can be used fluently
-
headers
public MultiMap headers()
- Returns:
- The HTTP headers
-
basicAuthentication
public HttpRequest<T> basicAuthentication(String id, String password)
- Parameters:
id
- the idpassword
- the password- Returns:
- a reference to this, so the API can be used fluently
-
basicAuthentication
public HttpRequest<T> basicAuthentication(Buffer id, Buffer password)
- Parameters:
id
- the idpassword
- the password- Returns:
- a reference to this, so the API can be used fluently
-
bearerTokenAuthentication
public HttpRequest<T> bearerTokenAuthentication(String bearerToken)
- Parameters:
bearerToken
- the bearer token- Returns:
- a reference to this, so the API can be used fluently
-
ssl
public HttpRequest<T> ssl(Boolean value)
-
timeout
public HttpRequest<T> timeout(long value)
- Parameters:
value
- The quantity of time in milliseconds.- Returns:
- a reference to this, so the API can be used fluently
-
addQueryParam
public HttpRequest<T> addQueryParam(String paramName, String paramValue)
- Parameters:
paramName
- the param nameparamValue
- the param value- Returns:
- a reference to this, so the API can be used fluently
-
setQueryParam
public HttpRequest<T> setQueryParam(String paramName, String paramValue)
- Parameters:
paramName
- the param nameparamValue
- the param value- Returns:
- a reference to this, so the API can be used fluently
-
followRedirects
public HttpRequest<T> followRedirects(boolean value)
- Parameters:
value
- true if redirections should be followed- Returns:
- a reference to this, so the API can be used fluently
-
expect
public HttpRequest<T> expect(Function<HttpResponse<Void>,ResponsePredicateResult> predicate)
- Parameters:
predicate
- the predicate- Returns:
- a reference to this, so the API can be used fluently
-
expect
public HttpRequest<T> expect(ResponsePredicate predicate)
- Parameters:
predicate
- the predicate- Returns:
- a reference to this, so the API can be used fluently
-
queryParams
public MultiMap queryParams()
- Returns:
- the current query parameters
-
copy
public HttpRequest<T> copy()
- Returns:
- a copy of this request
-
multipartMixed
public HttpRequest<T> multipartMixed(boolean allow)
- Parameters:
allow
-true
allows use of multipart mixed encoding- Returns:
- a reference to this, so the API can be used fluently
-
sendStream
public io.smallrye.mutiny.Uni<HttpResponse<T>> sendStream(ReadStream<Buffer> body)
Likesend()
but with an HTTP requestbody
stream.Unlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Parameters:
body
- the body- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
sendStreamAndAwait
public HttpResponse<T> sendStreamAndAwait(ReadStream<Buffer> body)
Blocking variant ofio.vertx.mutiny.ext.web.client.HttpRequest#sendStream(io.vertx.mutiny.core.streams.ReadStream
.) This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Parameters:
body
- the body- Returns:
- the HttpResponse
instance produced by the operation.
-
sendStreamAndForget
public void sendStreamAndForget(ReadStream<Buffer> body)
Variant ofio.vertx.mutiny.ext.web.client.HttpRequest#sendStream(io.vertx.mutiny.core.streams.ReadStream
that ignores the result of the operation.) This method subscribes on the result of
io.vertx.mutiny.ext.web.client.HttpRequest#sendStream(io.vertx.mutiny.core.streams.ReadStream
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from) io.vertx.mutiny.ext.web.client.HttpRequest#sendStream(io.vertx.mutiny.core.streams.ReadStream
but you don't need to compose it with other operations.) - Parameters:
body
- the body
-
sendStream
public io.smallrye.mutiny.Uni<HttpResponse<T>> sendStream(org.reactivestreams.Publisher<Buffer> body)
Likesend()
but with an HTTP requestbody
stream.Unlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Parameters:
body
- the body- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
sendStreamAndAwait
public HttpResponse<T> sendStreamAndAwait(org.reactivestreams.Publisher<Buffer> body)
Blocking variant ofsendStream(Publisher<Buffer>)
.This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Parameters:
body
- the body- Returns:
- the HttpResponse
instance produced by the operation.
-
sendStreamAndForget
public void sendStreamAndForget(org.reactivestreams.Publisher<Buffer> body)
Variant ofsendStream(Publisher<Buffer>)
that ignores the result of the operation.This method subscribes on the result of
sendStream(Publisher<Buffer>)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromsendStream(Publisher<Buffer>)
but you don't need to compose it with other operations.- Parameters:
body
- the body
-
sendBuffer
public io.smallrye.mutiny.Uni<HttpResponse<T>> sendBuffer(Buffer body)
Likesend()
but with an HTTP requestbody
buffer.Unlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Parameters:
body
- the body- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
sendBufferAndAwait
public HttpResponse<T> sendBufferAndAwait(Buffer body)
Blocking variant ofsendBuffer(io.vertx.mutiny.core.buffer.Buffer)
.This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Parameters:
body
- the body- Returns:
- the HttpResponse
instance produced by the operation.
-
sendBufferAndForget
public void sendBufferAndForget(Buffer body)
Variant ofsendBuffer(io.vertx.mutiny.core.buffer.Buffer)
that ignores the result of the operation.This method subscribes on the result of
sendBuffer(io.vertx.mutiny.core.buffer.Buffer)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromsendBuffer(io.vertx.mutiny.core.buffer.Buffer)
but you don't need to compose it with other operations.- Parameters:
body
- the body
-
sendJsonObject
public io.smallrye.mutiny.Uni<HttpResponse<T>> sendJsonObject(io.vertx.core.json.JsonObject body)
Likesend()
but with an HTTP requestbody
object encoded as json and the content type set toapplication/json
.Unlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Parameters:
body
- the body- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
sendJsonObjectAndAwait
public HttpResponse<T> sendJsonObjectAndAwait(io.vertx.core.json.JsonObject body)
Blocking variant ofsendJsonObject(JsonObject)
.This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Parameters:
body
- the body- Returns:
- the HttpResponse
instance produced by the operation.
-
sendJsonObjectAndForget
public void sendJsonObjectAndForget(io.vertx.core.json.JsonObject body)
Variant ofsendJsonObject(JsonObject)
that ignores the result of the operation.This method subscribes on the result of
sendJsonObject(JsonObject)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromsendJsonObject(JsonObject)
but you don't need to compose it with other operations.- Parameters:
body
- the body
-
sendJson
public io.smallrye.mutiny.Uni<HttpResponse<T>> sendJson(Object body)
Likesend()
but with an HTTP requestbody
object encoded as json and the content type set toapplication/json
.Unlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Parameters:
body
- the body- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
sendJsonAndAwait
public HttpResponse<T> sendJsonAndAwait(Object body)
Blocking variant ofsendJson(Object)
.This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Parameters:
body
- the body- Returns:
- the HttpResponse
instance produced by the operation.
-
sendJsonAndForget
public void sendJsonAndForget(Object body)
Variant ofsendJson(Object)
that ignores the result of the operation.This method subscribes on the result of
sendJson(Object)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromsendJson(Object)
but you don't need to compose it with other operations.- Parameters:
body
- the body
-
sendForm
public io.smallrye.mutiny.Uni<HttpResponse<T>> sendForm(MultiMap body)
Likesend()
but with an HTTP requestbody
multimap encoded as form and the content type set toapplication/x-www-form-urlencoded
.When the content type header is previously set to
multipart/form-data
it will be used instead.Unlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Parameters:
body
- the body- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
sendFormAndAwait
public HttpResponse<T> sendFormAndAwait(MultiMap body)
Blocking variant ofsendForm(io.vertx.mutiny.core.MultiMap)
.This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Parameters:
body
- the body- Returns:
- the HttpResponse
instance produced by the operation.
-
sendFormAndForget
public void sendFormAndForget(MultiMap body)
Variant ofsendForm(io.vertx.mutiny.core.MultiMap)
that ignores the result of the operation.This method subscribes on the result of
sendForm(io.vertx.mutiny.core.MultiMap)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromsendForm(io.vertx.mutiny.core.MultiMap)
but you don't need to compose it with other operations.- Parameters:
body
- the body
-
sendForm
public io.smallrye.mutiny.Uni<HttpResponse<T>> sendForm(MultiMap body, String charset)
Likesend()
but with an HTTP requestbody
multimap encoded as form and the content type set toapplication/x-www-form-urlencoded
.When the content type header is previously set to
multipart/form-data
it will be used instead. NOTE: the use of this method is strongly discouraged to use when the form is aapplication/x-www-form-urlencoded
encoded form since the charset to use must be UTF-8.Unlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Parameters:
body
- the bodycharset
-- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
sendFormAndAwait
public HttpResponse<T> sendFormAndAwait(MultiMap body, String charset)
Blocking variant ofsendForm(io.vertx.mutiny.core.MultiMap,String)
.This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Parameters:
body
- the bodycharset
-- Returns:
- the HttpResponse
instance produced by the operation.
-
sendFormAndForget
public void sendFormAndForget(MultiMap body, String charset)
Variant ofsendForm(io.vertx.mutiny.core.MultiMap,String)
that ignores the result of the operation.This method subscribes on the result of
sendForm(io.vertx.mutiny.core.MultiMap,String)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromsendForm(io.vertx.mutiny.core.MultiMap,String)
but you don't need to compose it with other operations.- Parameters:
body
- the bodycharset
-
-
sendMultipartForm
public io.smallrye.mutiny.Uni<HttpResponse<T>> sendMultipartForm(MultipartForm body)
Likesend()
but with an HTTP requestbody
multimap encoded as form and the content type set tomultipart/form-data
. You may use this method to send attributes and upload files.Unlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Parameters:
body
- the body- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
sendMultipartFormAndAwait
public HttpResponse<T> sendMultipartFormAndAwait(MultipartForm body)
Blocking variant ofsendMultipartForm(io.vertx.mutiny.ext.web.multipart.MultipartForm)
.This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Parameters:
body
- the body- Returns:
- the HttpResponse
instance produced by the operation.
-
sendMultipartFormAndForget
public void sendMultipartFormAndForget(MultipartForm body)
Variant ofsendMultipartForm(io.vertx.mutiny.ext.web.multipart.MultipartForm)
that ignores the result of the operation.This method subscribes on the result of
sendMultipartForm(io.vertx.mutiny.ext.web.multipart.MultipartForm)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromsendMultipartForm(io.vertx.mutiny.ext.web.multipart.MultipartForm)
but you don't need to compose it with other operations.- Parameters:
body
- the body
-
send
public io.smallrye.mutiny.Uni<HttpResponse<T>> send()
Send a request, thehandler
will receive the response as anHttpResponse
.Unlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
sendAndAwait
public HttpResponse<T> sendAndAwait()
Blocking variant ofsend()
.This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Returns:
- the HttpResponse
instance produced by the operation.
-
sendAndForget
public void sendAndForget()
-
putHeader
public HttpRequest<T> putHeader(String name, Iterable<String> value)
- Parameters:
name
- the header namevalue
- the header value- Returns:
- a reference to this, so the API can be used fluently
-
authentication
public HttpRequest<T> authentication(io.vertx.ext.auth.authentication.Credentials credentials)
- Parameters:
credentials
- the credentials to use.- Returns:
- a reference to this, so the API can be used fluently
-
newInstance
public static <T> HttpRequest<T> newInstance(io.vertx.ext.web.client.HttpRequest arg)
-
newInstance
public static <T> HttpRequest<T> newInstance(io.vertx.ext.web.client.HttpRequest arg, TypeArg<T> __typeArg_T)
-
-