Class HttpRequest<T>

java.lang.Object
io.vertx.mutiny.ext.web.client.HttpRequest<T>
All Implemented Interfaces:
MutinyDelegate

public class HttpRequest<T> extends Object implements MutinyDelegate
A client-side HTTP request.

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

can be called. The 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 the original non Mutiny-ified interface using Vert.x codegen.

  • Field Details

  • Constructor Details

    • HttpRequest

      public HttpRequest(io.vertx.ext.web.client.HttpRequest delegate)
    • HttpRequest

      public HttpRequest(Object delegate, TypeArg<T> typeArg_0)
    • HttpRequest

      public HttpRequest(io.vertx.ext.web.client.HttpRequest delegate, TypeArg<T> typeArg_0)
  • Method Details

    • getDelegate

      public io.vertx.ext.web.client.HttpRequest getDelegate()
      Specified by:
      getDelegate in interface MutinyDelegate
      Returns:
      the delegate used by this Mutiny object of generated type
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • 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
    • method

      public io.vertx.core.http.HttpMethod method()
      Returns:
      the request method
    • port

      public HttpRequest<T> port(int value)
      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

      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
    • bodyCodec

      public BodyCodec<T> bodyCodec()
      Returns:
      the request body codec
    • host

      public HttpRequest<T> host(String value)
      Parameters:
      value -
      Returns:
      a reference to this, so the API can be used fluently
    • host

      public String host()
      Returns:
      the request host or null when none is set for absolute URI templates
    • virtualHost

      public HttpRequest<T> virtualHost(String value)
      Parameters:
      value -
      Returns:
      a reference to this, so the API can be used fluently
    • virtualHost

      public String virtualHost()
      Returns:
      the request virtual host if any or null
    • uri

      public HttpRequest<T> uri(String value)
      Parameters:
      value -
      Returns:
      a reference to this, so the API can be used fluently
    • uri

      public String uri()
      Returns:
      the request uri or null when none is set for absolute URI templates
    • 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 name
      value - 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 id
      password - 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 id
      password - 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)
      Parameters:
      value -
      Returns:
      a reference to this, so the API can be used fluently
    • ssl

      public Boolean ssl()
      Returns:
      whether the request uses SSL or null when none is set for absolute URI templates
    • timeout

      public HttpRequest<T> timeout(long value)
      Parameters:
      value -
      Returns:
      the instance of HttpRequest to chain method calls.
    • timeout

      public long timeout()
      Returns:
      the current timeout in milliseconds
    • idleTimeout

      public HttpRequest<T> idleTimeout(long timeout)
      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

      public HttpRequest<T> connectTimeout(long timeout)
      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

      public HttpRequest<T> addQueryParam(String paramName, String paramValue)
      Parameters:
      paramName - the param name
      paramValue - 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 name
      paramValue - the param value
      Returns:
      a reference to this, so the API can be used fluently
    • setTemplateParam

      public HttpRequest<T> setTemplateParam(String paramName, String paramValue)
      Parameters:
      paramName - the param name
      paramValue - the param value
      Returns:
      a reference to this, so the API can be used fluently
    • setTemplateParam

      public HttpRequest<T> setTemplateParam(String paramName, List<String> paramValue)
      Parameters:
      paramName - the param name
      paramValue - the param value
      Returns:
      a reference to this, so the API can be used fluently
    • setTemplateParam

      public HttpRequest<T> setTemplateParam(String paramName, Map<String,String> paramValue)
      Parameters:
      paramName - the param name
      paramValue - 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
    • followRedirects

      public boolean followRedirects()
      Returns:
      whether to follow request redirections
    • proxy

      public HttpRequest<T> proxy(io.vertx.core.net.ProxyOptions proxyOptions)
      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.
      instead use HttpResponseExpectation along with Future.expecting(Expectation)
      Parameters:
      predicate - the predicate
      Returns:
      a reference to this, so the API can be used fluently
    • expect

      @Deprecated public HttpRequest<T> expect(ResponsePredicate predicate)
      Deprecated.
      instead use HttpResponseExpectation along with Future.expecting(Expectation)
      Parameters:
      predicate - the predicate
      Returns:
      a reference to this, so the API can be used fluently
    • expectations

      @Deprecated public List<ResponsePredicate> expectations()
      Deprecated.
      Returns:
      a read-only list of the response predicate expectations
    • queryParams

      public MultiMap queryParams()
      Returns:
      the current query parameters
    • templateParams

      public Variables templateParams()
      Returns:
      the current request URI template 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
    • multipartMixed

      public boolean multipartMixed()
      Returns:
      whether multipart mixed encoding is allowed
    • traceOperation

      public HttpRequest<T> traceOperation(String traceOperation)
      Parameters:
      traceOperation - Name of operation to use in traces
      Returns:
      a reference to this, so the API can be used fluently
    • traceOperation

      public String traceOperation()
      Returns:
      the trace operation name override
    • sendStream

      @CheckReturnValue public io.smallrye.mutiny.Uni<HttpResponse<T>> sendStream(ReadStream<Buffer> body)
      Like send() but with an HTTP request body 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 of 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 of sendStream(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 from sendStream(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)
      Like send() but with an HTTP request body 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(Flow.Publisher<Buffer> body)
      Blocking variant of sendStream(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

      public void sendStreamAndForget(Flow.Publisher<Buffer> body)
      Variant of sendStream(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 from sendStream(Flow$Publisher) but you don't need to compose it with other operations.

      Parameters:
      body - the body
    • sendBuffer

      @CheckReturnValue public io.smallrye.mutiny.Uni<HttpResponse<T>> sendBuffer(Buffer body)
      Like send() but with an HTTP request body 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 of sendBuffer(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 of sendBuffer(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 from sendBuffer(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)
      Like send() but with an HTTP request body object encoded as json and the content type set to application/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 of sendJsonObject(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 of sendJsonObject(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 from sendJsonObject(JsonObject) but you don't need to compose it with other operations.

      Parameters:
      body - the body
    • sendJson

      @CheckReturnValue public io.smallrye.mutiny.Uni<HttpResponse<T>> sendJson(Object body)
      Like send() but with an HTTP request body object encoded as json and the content type set to application/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 of sendJson(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 of sendJson(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 from sendJson(Object) 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)
      Like send() but with an HTTP request body multimap encoded as form and the content type set to application/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 of sendForm(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 of sendForm(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 from sendForm(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)
      Like send() but with an HTTP request body multimap encoded as form and the content type set to application/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 a application/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 body
      charset -
      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 of sendForm(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 body
      charset -
      Returns:
      the HttpResponse instance produced by the operation.
    • sendFormAndForget

      public void sendFormAndForget(MultiMap body, String charset)
      Variant of sendForm(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 from sendForm(io.vertx.mutiny.core.MultiMap,String) but you don't need to compose it with other operations.

      Parameters:
      body - the body
      charset -
    • sendMultipartForm

      @CheckReturnValue public io.smallrye.mutiny.Uni<HttpResponse<T>> sendMultipartForm(MultipartForm body)
      Like send() but with an HTTP request body multimap encoded as form and the content type set to multipart/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 of sendMultipartForm(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 of sendMultipartForm(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 from sendMultipartForm(io.vertx.mutiny.ext.web.multipart.MultipartForm) but you don't need to compose it with other operations.

      Parameters:
      body - the body
    • send

      @CheckReturnValue public io.smallrye.mutiny.Uni<HttpResponse<T>> send()
      Send a request, the handler will receive the response as an HttpResponse.

      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 of send().

      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()
      Variant of send() that ignores the result of the operation.

      This method subscribes on the result of send(), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from send() but you don't need to compose it with other operations.

    • putHeader

      public HttpRequest<T> putHeader(String name, Iterable<String> value)
      Parameters:
      name - the header name
      value - 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)