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) |
Modifier and Type | Method and Description |
---|---|
HttpRequest<T> |
addQueryParam(String paramName,
String paramValue)
Add a query parameter to the request.
|
<U> HttpRequest<U> |
as(BodyCodec<U> responseCodec)
Configure the request to decode the response with the
responseCodec . |
HttpRequest<T> |
copy()
Copy this request
|
HttpRequest |
getDelegate() |
MultiMap |
headers() |
HttpRequest<T> |
host(String value)
Configure the request to use a new host
value . |
HttpRequest<T> |
method(HttpMethod value)
Configure the request to use a new method
value . |
static <T> HttpRequest |
newInstance(HttpRequest arg) |
static <T> HttpRequest |
newInstance(HttpRequest arg,
TypeArg<T> __typeArg_T) |
HttpRequest<T> |
port(int value)
Configure the request to use a new port
value . |
HttpRequest<T> |
putHeader(String name,
String value)
Configure the request to add a new HTTP header.
|
MultiMap |
queryParams()
Return the current query parameters.
|
rx.Single<HttpResponse<T>> |
rxSend()
Send a request, the
handler will receive the response as an HttpResponse . |
rx.Single<HttpResponse<T>> |
rxSendBuffer(Buffer body)
Like
send(io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.ext.web.client.HttpResponse<T>>>) but with an HTTP request body buffer. |
rx.Single<HttpResponse<T>> |
rxSendForm(MultiMap body)
Like
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 . |
rx.Single<HttpResponse<T>> |
rxSendJson(Object body)
Like
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 . |
rx.Single<HttpResponse<T>> |
rxSendJsonObject(JsonObject body)
Like
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 . |
rx.Single<HttpResponse<T>> |
rxSendStream(rx.Observable<Buffer> body)
Like
send(io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.ext.web.client.HttpResponse<T>>>) but with an HTTP request body stream. |
rx.Single<HttpResponse<T>> |
rxSendStream(ReadStream<Buffer> body)
Like
send(io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.ext.web.client.HttpResponse<T>>>) but with an HTTP request body stream. |
void |
send(Handler<AsyncResult<HttpResponse<T>>> handler)
Send a request, the
handler will receive the response as an HttpResponse . |
void |
sendBuffer(Buffer body,
Handler<AsyncResult<HttpResponse<T>>> handler)
Like
send(io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.ext.web.client.HttpResponse<T>>>) but with an HTTP request body buffer. |
void |
sendForm(MultiMap body,
Handler<AsyncResult<HttpResponse<T>>> handler)
Like
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 . |
void |
sendJson(Object body,
Handler<AsyncResult<HttpResponse<T>>> handler)
Like
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 . |
void |
sendJsonObject(JsonObject body,
Handler<AsyncResult<HttpResponse<T>>> handler)
Like
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 . |
void |
sendStream(rx.Observable<Buffer> body,
Handler<AsyncResult<HttpResponse<T>>> handler)
Like
send(io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.ext.web.client.HttpResponse<T>>>) but with an HTTP request body stream. |
void |
sendStream(ReadStream<Buffer> body,
Handler<AsyncResult<HttpResponse<T>>> handler)
Like
send(io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.ext.web.client.HttpResponse<T>>>) but with an HTTP request body stream. |
HttpRequest<T> |
setQueryParam(String paramName,
String paramValue)
Set a query parameter to the request.
|
HttpRequest<T> |
timeout(long value)
Configures the amount of time in milliseconds after which if the request does not return any data within the timeout
period an
TimeoutException fails the request. |
HttpRequest<T> |
uri(String value)
Configure the request to use a new request URI
value . |
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> 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 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 rx.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 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 rx.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 rx.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 rx.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 rx.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 rx.Single<HttpResponse<T>> rxSend()
handler
will receive the response as an HttpResponse
.public void sendStream(rx.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 rx.Single<HttpResponse<T>> rxSendStream(rx.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 static <T> HttpRequest newInstance(HttpRequest arg)
public static <T> HttpRequest newInstance(HttpRequest arg, TypeArg<T> __typeArg_T)
Copyright © 2017. All rights reserved.