public class HttpRequest<T> extends Object
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(io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.ext.web.client.HttpResponse<T>>>)
sendStream(io.vertx.rxjava.core.streams.ReadStream<io.vertx.rxjava.core.buffer.Buffer>, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.ext.web.client.HttpResponse<T>>>)
sendJson(java.lang.Object, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.ext.web.client.HttpResponse<T>>>)
()}sendForm(io.vertx.rxjava.core.MultiMap, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.ext.web.client.HttpResponse<T>>>)
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
HttpResponse
instance when the HTTP response has been receivedMost 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 RX-ified interface using Vert.x codegen.Modifier and Type | Field and Description |
---|---|
static TypeArg<HttpRequest> |
__TYPE_ARG |
TypeArg<T> |
__typeArg_0 |
Constructor and Description |
---|
HttpRequest(HttpRequest delegate) |
HttpRequest(HttpRequest delegate,
TypeArg<T> typeArg_0) |
public static final TypeArg<HttpRequest> __TYPE_ARG
public HttpRequest(HttpRequest delegate)
public HttpRequest(HttpRequest delegate, TypeArg<T> typeArg_0)
public HttpRequest getDelegate()
public HttpRequest<T> method(HttpMethod value)
value
.value
- public HttpRequest<T> port(int value)
value
.value
- public <U> HttpRequest<U> as(BodyCodec<U> responseCodec)
responseCodec
.responseCodec
- the response codecpublic HttpRequest<T> host(String value)
value
.value
- public HttpRequest<T> uri(String value)
value
.
When the uri has query parameters, they are set in the queryParams()
multimap, overwritting
any parameters previously set.
value
- public HttpRequest<T> putHeader(String name, String value)
name
- the header namevalue
- the header valuepublic MultiMap headers()
public HttpRequest<T> ssl(boolean value)
public HttpRequest<T> timeout(long value)
TimeoutException
fails the request.
Setting zero or a negative value
disables the timeout.
value
- The quantity of time in milliseconds.public HttpRequest<T> addQueryParam(String paramName, String paramValue)
paramName
- the param nameparamValue
- the param valuepublic HttpRequest<T> setQueryParam(String paramName, String paramValue)
paramName
- the param nameparamValue
- the param valuepublic HttpRequest<T> followRedirects(boolean value)
value
- true if redirections should be followedpublic MultiMap queryParams()
public HttpRequest<T> copy()
public void sendStream(ReadStream<Buffer> body, Handler<AsyncResult<HttpResponse<T>>> handler)
send(io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.ext.web.client.HttpResponse<T>>>)
but with an HTTP request body
stream.body
- the bodyhandler
- public Single<HttpResponse<T>> rxSendStream(ReadStream<Buffer> body)
send(io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.ext.web.client.HttpResponse<T>>>)
but with an HTTP request body
stream.body
- the bodypublic void sendStream(Observable<Buffer> body, Handler<AsyncResult<HttpResponse<T>>> handler)
send(io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.ext.web.client.HttpResponse<T>>>)
but with an HTTP request body
stream.body
- the bodyhandler
- public Single<HttpResponse<T>> rxSendStream(Observable<Buffer> body)
send(io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.ext.web.client.HttpResponse<T>>>)
but with an HTTP request body
stream.body
- the bodypublic void sendBuffer(Buffer body, Handler<AsyncResult<HttpResponse<T>>> handler)
send(io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.ext.web.client.HttpResponse<T>>>)
but with an HTTP request body
buffer.body
- the bodyhandler
- public Single<HttpResponse<T>> rxSendBuffer(Buffer body)
send(io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.ext.web.client.HttpResponse<T>>>)
but with an HTTP request body
buffer.body
- the bodypublic void sendJsonObject(JsonObject body, Handler<AsyncResult<HttpResponse<T>>> handler)
send(io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.ext.web.client.HttpResponse<T>>>)
but with an HTTP request body
object encoded as json and the content type
set to application/json
.body
- the bodyhandler
- public Single<HttpResponse<T>> rxSendJsonObject(JsonObject body)
send(io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.ext.web.client.HttpResponse<T>>>)
but with an HTTP request body
object encoded as json and the content type
set to application/json
.body
- the bodypublic void sendJson(Object body, Handler<AsyncResult<HttpResponse<T>>> handler)
send(io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.ext.web.client.HttpResponse<T>>>)
but with an HTTP request body
object encoded as json and the content type
set to application/json
.body
- the bodyhandler
- public Single<HttpResponse<T>> rxSendJson(Object body)
send(io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.ext.web.client.HttpResponse<T>>>)
but with an HTTP request body
object encoded as json and the content type
set to application/json
.body
- the bodypublic void sendForm(MultiMap body, Handler<AsyncResult<HttpResponse<T>>> handler)
send(io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.ext.web.client.HttpResponse<T>>>)
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.
body
- the bodyhandler
- public Single<HttpResponse<T>> rxSendForm(MultiMap body)
send(io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.ext.web.client.HttpResponse<T>>>)
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.
body
- the bodypublic void send(Handler<AsyncResult<HttpResponse<T>>> handler)
handler
will receive the response as an HttpResponse
.handler
- public Single<HttpResponse<T>> rxSend()
handler
will receive the response as an HttpResponse
.public static <T> HttpRequest<T> newInstance(HttpRequest arg)
public static <T> HttpRequest<T> newInstance(HttpRequest arg, TypeArg<T> __typeArg_T)
Copyright © 2017. All rights reserved.