Class HttpRequest<T>
- All Implemented Interfaces:
MutinyDelegate
Instances are created by an WebClient
instance, via one of the methods corresponding to the specific
HTTP methods such as WebClient.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 -
Constructor Summary
ConstructorsConstructorDescriptionHttpRequest
(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
Modifier and TypeMethodDescriptionaddQueryParam
(String paramName, String paramValue) <U> HttpRequest<U>
authentication
(io.vertx.ext.auth.authentication.Credentials credentials) basicAuthentication
(Buffer id, Buffer password) basicAuthentication
(String id, String password) bearerTokenAuthentication
(String bearerToken) long
connectTimeout
(long timeout) copy()
boolean
expect
(ResponsePredicate predicate) Deprecated.expect
(Function<HttpResponse<Void>, ResponsePredicateResult> predicate) Deprecated.instead useHttpResponseExpectation
along withFuture.expecting(Expectation)
Deprecated.boolean
followRedirects
(boolean value) io.vertx.ext.web.client.HttpRequest
int
hashCode()
headers()
host()
long
idleTimeout
(long timeout) io.vertx.core.http.HttpMethod
method()
method
(io.vertx.core.http.HttpMethod value) boolean
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) int
port()
port
(int value) io.vertx.core.net.ProxyOptions
proxy()
proxy
(io.vertx.core.net.ProxyOptions proxyOptions) putHeaders
(MultiMap headers) io.smallrye.mutiny.Uni<HttpResponse<T>>
send()
Send a request, thehandler
will receive the response as anHttpResponse
.Blocking variant ofsend()
.void
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.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>>
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>>
Likesend()
but with an HTTP requestbody
multimap encoded as form and the content type set toapplication/x-www-form-urlencoded
.sendFormAndAwait
(MultiMap body) Blocking variant ofsendForm(io.vertx.mutiny.core.MultiMap)
.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>>
Likesend()
but with an HTTP requestbody
object encoded as json and the content type set toapplication/json
.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
.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>>
Likesend()
but with an HTTP requestbody
multimap encoded as form and the content type set tomultipart/form-data
.Blocking variant ofsendMultipartForm(io.vertx.mutiny.ext.web.multipart.MultipartForm)
.void
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
(Flow.Publisher<Buffer> body) Likesend()
but with an HTTP requestbody
stream.sendStreamAndAwait
(ReadStream<Buffer> body) Blocking variant ofsendStream(io.vertx.mutiny.core.streams.ReadStream)
.Blocking variant ofsendStream(Flow$Publisher)
.void
sendStreamAndForget
(ReadStream<Buffer> body) Variant ofsendStream(io.vertx.mutiny.core.streams.ReadStream)
that ignores the result of the operation.void
Variant ofsendStream(Flow$Publisher)
that ignores the result of the operation.setQueryParam
(String paramName, String paramValue) setTemplateParam
(String paramName, String paramValue) setTemplateParam
(String paramName, List<String> paramValue) setTemplateParam
(String paramName, Map<String, String> paramValue) ssl()
long
timeout()
timeout
(long value) toString()
traceOperation
(String traceOperation) uri()
virtualHost
(String value)
-
Field Details
-
__TYPE_ARG
-
__typeArg_0
-
-
Constructor Details
-
HttpRequest
public HttpRequest(io.vertx.ext.web.client.HttpRequest delegate) -
HttpRequest
-
HttpRequest
-
-
Method Details
-
getDelegate
public io.vertx.ext.web.client.HttpRequest getDelegate()- Specified by:
getDelegate
in interfaceMutinyDelegate
- Returns:
- the delegate used by this Mutiny object of generated type
-
toString
-
equals
-
hashCode
public int hashCode() -
method
- Parameters:
value
-- Returns:
- a reference to this, so the API can be used fluently
-
method
public io.vertx.core.http.HttpMethod method()- Returns:
- the request method
-
port
- Parameters:
value
-- Returns:
- a reference to this, so the API can be used fluently
-
port
public int port()- Returns:
- the request port or
0
when none is set for absolute URI templates
-
as
- Parameters:
responseCodec
- the response codec- Returns:
- a reference to this, so the API can be used fluently
-
bodyCodec
- Returns:
- the request body codec
-
host
- Parameters:
value
-- Returns:
- a reference to this, so the API can be used fluently
-
host
- Returns:
- the request host or
null
when none is set for absolute URI templates
-
virtualHost
- Parameters:
value
-- Returns:
- a reference to this, so the API can be used fluently
-
virtualHost
- Returns:
- the request virtual host if any or
null
-
uri
- Parameters:
value
-- Returns:
- a reference to this, so the API can be used fluently
-
uri
- Returns:
- the request uri or
null
when none is set for absolute URI templates
-
putHeaders
- Parameters:
headers
- The HTTP headers- Returns:
- a reference to this, so the API can be used fluently
-
putHeader
- Parameters:
name
- the header namevalue
- the header value- Returns:
- a reference to this, so the API can be used fluently
-
headers
- Returns:
- The HTTP headers
-
basicAuthentication
- Parameters:
id
- the idpassword
- the password- Returns:
- a reference to this, so the API can be used fluently
-
basicAuthentication
- Parameters:
id
- the idpassword
- the password- Returns:
- a reference to this, so the API can be used fluently
-
bearerTokenAuthentication
- Parameters:
bearerToken
- the bearer token- Returns:
- a reference to this, so the API can be used fluently
-
ssl
- Parameters:
value
-- Returns:
- a reference to this, so the API can be used fluently
-
ssl
- Returns:
- whether the request uses SSL or
null
when none is set for absolute URI templates
-
timeout
- Parameters:
value
-- Returns:
- the instance of HttpRequest
to chain method calls.
-
timeout
public long timeout()- Returns:
- the current timeout in milliseconds
-
idleTimeout
- Parameters:
timeout
- the amount of time in milliseconds.- Returns:
- a reference to this, so the API can be used fluently
-
idleTimeout
public long idleTimeout()- Returns:
- the idle timeout in milliseconds
-
connectTimeout
- Parameters:
timeout
- the amount of time in milliseconds.- Returns:
- a reference to this, so the API can be used fluently
-
connectTimeout
public long connectTimeout()- Returns:
- the connect timeout in milliseconds
-
addQueryParam
- Parameters:
paramName
- the param nameparamValue
- the param value- Returns:
- a reference to this, so the API can be used fluently
-
setQueryParam
- Parameters:
paramName
- the param nameparamValue
- the param value- Returns:
- a reference to this, so the API can be used fluently
-
setTemplateParam
- Parameters:
paramName
- the param nameparamValue
- the param value- Returns:
- a reference to this, so the API can be used fluently
-
setTemplateParam
- Parameters:
paramName
- the param nameparamValue
- the param value- Returns:
- a reference to this, so the API can be used fluently
-
setTemplateParam
- Parameters:
paramName
- the param nameparamValue
- the param value- Returns:
- a reference to this, so the API can be used fluently
-
followRedirects
- Parameters:
value
- true if redirections should be followed- Returns:
- a reference to this, so the API can be used fluently
-
followRedirects
public boolean followRedirects()- Returns:
- whether to follow request redirections
-
proxy
- Parameters:
proxyOptions
- The proxy options- Returns:
- a reference to this, so the API can be used fluently
-
proxy
public io.vertx.core.net.ProxyOptions proxy()- Returns:
- the proxy for this request
-
expect
@Deprecated public HttpRequest<T> expect(Function<HttpResponse<Void>, ResponsePredicateResult> predicate) Deprecated.instead useHttpResponseExpectation
along withFuture.expecting(Expectation)
- Parameters:
predicate
- the predicate- Returns:
- a reference to this, so the API can be used fluently
-
expect
Deprecated.instead useHttpResponseExpectation
along withFuture.expecting(Expectation)
- Parameters:
predicate
- the predicate- Returns:
- a reference to this, so the API can be used fluently
-
expectations
Deprecated.- Returns:
- a read-only list of the response predicate expectations
-
queryParams
- Returns:
- the current query parameters
-
templateParams
- Returns:
- the current request URI template parameters
-
copy
- Returns:
- a copy of this request
-
multipartMixed
- Parameters:
allow
-true
allows use of multipart mixed encoding- Returns:
- a reference to this, so the API can be used fluently
-
multipartMixed
public boolean multipartMixed()- Returns:
- whether multipart mixed encoding is allowed
-
traceOperation
- Parameters:
traceOperation
- Name of operation to use in traces- Returns:
- a reference to this, so the API can be used fluently
-
traceOperation
- Returns:
- the trace operation name override
-
sendStream
@CheckReturnValue 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
Blocking variant ofsendStream(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
Variant ofsendStream(io.vertx.mutiny.core.streams.ReadStream)
that ignores the result of the operation.This method subscribes on the result of
sendStream(io.vertx.mutiny.core.streams.ReadStream)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromsendStream(io.vertx.mutiny.core.streams.ReadStream)
but you don't need to compose it with other operations.- Parameters:
body
- the body
-
sendStream
@CheckReturnValue public io.smallrye.mutiny.Uni<HttpResponse<T>> sendStream(Flow.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
Blocking variant ofsendStream(Flow$Publisher)
.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
Variant ofsendStream(Flow$Publisher)
that ignores the result of the operation.This method subscribes on the result of
sendStream(Flow$Publisher)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromsendStream(Flow$Publisher)
but you don't need to compose it with other operations.- Parameters:
body
- the body
-
sendBuffer
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
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
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
@CheckReturnValue 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
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
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
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
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
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
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
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
@CheckReturnValue 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
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
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
@CheckReturnValue 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
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
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
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
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
- Parameters:
name
- the header namevalue
- the header value- Returns:
- a reference to this, so the API can be used fluently
-
authentication
- Parameters:
credentials
- the credentials to use.- Returns:
- a reference to this, so the API can be used fluently
-
newInstance
-
newInstance
public static <T> HttpRequest<T> newInstance(io.vertx.ext.web.client.HttpRequest arg, TypeArg<T> __typeArg_T)
-
HttpResponseExpectation
along withFuture.expecting(Expectation)