public class HttpRequestImpl<T> extends Object implements HttpRequest<T>
| Modifier and Type | Field and Description |
|---|---|
List<ResponsePredicate> |
expectations |
| 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> |
authentication(Credentials credentials)
Configure the request to perform HTTP Authentication.
|
HttpRequest<T> |
copy()
Copy this request
|
HttpRequest<T> |
expect(ResponsePredicate expectation)
Add an expectation that the response is valid according to the provided
predicate. |
boolean |
followRedirects() |
HttpRequest<T> |
followRedirects(boolean value)
Set wether or not to follow the directs for the request.
|
MultiMap |
headers() |
String |
host() |
HttpRequest<T> |
host(String value)
Configure the request to use a new host
value. |
HttpMethod |
method() |
HttpRequest<T> |
method(HttpMethod value)
Configure the request to use a new method
value. |
HttpRequest<T> |
multipartMixed(boolean allow)
Allow or disallow multipart mixed encoding when sending
MultipartForm having files sharing the same
file name. |
int |
port() |
HttpRequest<T> |
port(int value)
Configure the request to use a new port
value. |
HttpRequest<T> |
putHeader(String name,
Iterable<String> value)
Configure the request to set a new HTTP header with multiple values.
|
HttpRequest<T> |
putHeader(String name,
String value)
Configure the request to set a new HTTP header.
|
HttpRequest<T> |
putHeaders(MultiMap headers)
Configure the request to add multiple HTTP headers .
|
MultiMap |
queryParams()
Return the current query parameters.
|
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
HttpRequest.send(Handler) but with an HTTP request body buffer. |
void |
sendForm(MultiMap body,
Handler<AsyncResult<HttpResponse<T>>> handler)
Like
HttpRequest.send(Handler) 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
HttpRequest.send(Handler) 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
HttpRequest.send(Handler) but with an HTTP request body object encoded as json and the content type
set to application/json. |
void |
sendMultipartForm(MultipartForm body,
Handler<AsyncResult<HttpResponse<T>>> handler)
Like
HttpRequest.send(Handler) but with an HTTP request body multimap encoded as form and the content type
set to multipart/form-data. |
void |
sendStream(ReadStream<Buffer> body,
Handler<AsyncResult<HttpResponse<T>>> handler)
Like
HttpRequest.send(Handler) but with an HTTP request body stream. |
HttpRequest<T> |
setQueryParam(String paramName,
String paramValue)
Set a query parameter to the request.
|
Boolean |
ssl() |
HttpRequest<T> |
ssl(Boolean value) |
long |
timeout() |
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. |
String |
uri() |
HttpRequest<T> |
uri(String value)
Configure the request to use a new request URI
value. |
String |
virtualHost() |
HttpRequest<T> |
virtualHost(String value)
Configure the request to use a virtual host
value. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitbasicAuthentication, basicAuthentication, bearerTokenAuthentication, expect, send, sendBuffer, sendForm, sendJson, sendJsonObject, sendMultipartForm, sendStreampublic List<ResponsePredicate> expectations
public <U> HttpRequest<U> as(BodyCodec<U> responseCodec)
HttpRequestresponseCodec.as in interface HttpRequest<T>responseCodec - the response codecpublic HttpRequest<T> method(HttpMethod value)
HttpRequestvalue.method in interface HttpRequest<T>public HttpMethod method()
public HttpRequest<T> port(int value)
HttpRequestvalue.port in interface HttpRequest<T>public int port()
public HttpRequest<T> host(String value)
HttpRequestvalue.host in interface HttpRequest<T>public String host()
public HttpRequest<T> virtualHost(String value)
HttpRequestvalue.
Usually the header host (:authority pseudo header for HTTP/2) is set from the request host value
since this host value resolves to the server IP address.
Sometimes you need to set a host header for an address that does not resolve to the server IP address.
The virtual host value overrides the value of the actual host header (:authority pseudo header
for HTTP/2).
The virtual host is also be used for SNI.virtualHost in interface HttpRequest<T>public String virtualHost()
public HttpRequest<T> uri(String value)
HttpRequestvalue.
When the uri has query parameters, they are set in the HttpRequest.queryParams() multimap, overwritting
any parameters previously set.
uri in interface HttpRequest<T>public String uri()
public HttpRequest<T> putHeaders(MultiMap headers)
HttpRequestputHeaders in interface HttpRequest<T>headers - The HTTP headerspublic HttpRequest<T> putHeader(String name, String value)
HttpRequestputHeader in interface HttpRequest<T>name - the header namevalue - the header valuepublic HttpRequest<T> putHeader(String name, Iterable<String> value)
HttpRequestputHeader in interface HttpRequest<T>name - the header namevalue - the header valuepublic MultiMap headers()
headers in interface HttpRequest<T>public HttpRequest<T> authentication(Credentials credentials)
HttpRequest
Performs a generic authentication using the credentials provided by the user. For the sake of validation safety
it is recommended that Credentials.applyHttpChallenge(String) is called to ensure that the credentials
are applicable to the HTTP Challenged received on a previous request that returned a 401 response code.
authentication in interface HttpRequest<T>credentials - the credentials to use.public HttpRequest<T> ssl(Boolean value)
ssl in interface HttpRequest<T>public Boolean ssl()
public HttpRequest<T> timeout(long value)
HttpRequestTimeoutException fails the request.
Setting zero or a negative value disables the timeout.
timeout in interface HttpRequest<T>value - The quantity of time in milliseconds.public long timeout()
public HttpRequest<T> addQueryParam(String paramName, String paramValue)
HttpRequestaddQueryParam in interface HttpRequest<T>paramName - the param nameparamValue - the param valuepublic HttpRequest<T> setQueryParam(String paramName, String paramValue)
HttpRequestsetQueryParam in interface HttpRequest<T>paramName - the param nameparamValue - the param valuepublic HttpRequest<T> followRedirects(boolean value)
HttpRequestfollowRedirects in interface HttpRequest<T>value - true if redirections should be followedpublic boolean followRedirects()
public HttpRequest<T> expect(ResponsePredicate expectation)
HttpRequestpredicate.
Multiple predicates can be added.
expect in interface HttpRequest<T>expectation - the predicatepublic MultiMap queryParams()
HttpRequestqueryParams in interface HttpRequest<T>public HttpRequest<T> copy()
HttpRequestcopy in interface HttpRequest<T>public HttpRequest<T> multipartMixed(boolean allow)
HttpRequestMultipartForm having files sharing the same
file name.
true.
false if you want to achieve the behavior for HTML5.multipartMixed in interface HttpRequest<T>allow - true allows use of multipart mixed encodingpublic void sendStream(ReadStream<Buffer> body, Handler<AsyncResult<HttpResponse<T>>> handler)
HttpRequestHttpRequest.send(Handler) but with an HTTP request body stream.sendStream in interface HttpRequest<T>body - the bodypublic void send(Handler<AsyncResult<HttpResponse<T>>> handler)
HttpRequesthandler will receive the response as an HttpResponse.send in interface HttpRequest<T>public void sendBuffer(Buffer body, Handler<AsyncResult<HttpResponse<T>>> handler)
HttpRequestHttpRequest.send(Handler) but with an HTTP request body buffer.sendBuffer in interface HttpRequest<T>body - the bodypublic void sendJsonObject(JsonObject body, Handler<AsyncResult<HttpResponse<T>>> handler)
HttpRequestHttpRequest.send(Handler) but with an HTTP request body object encoded as json and the content type
set to application/json.sendJsonObject in interface HttpRequest<T>body - the bodypublic void sendJson(Object body, Handler<AsyncResult<HttpResponse<T>>> handler)
HttpRequestHttpRequest.send(Handler) but with an HTTP request body object encoded as json and the content type
set to application/json.sendJson in interface HttpRequest<T>body - the bodypublic void sendForm(MultiMap body, Handler<AsyncResult<HttpResponse<T>>> handler)
HttpRequestHttpRequest.send(Handler) 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.
sendForm in interface HttpRequest<T>body - the bodypublic void sendMultipartForm(MultipartForm body, Handler<AsyncResult<HttpResponse<T>>> handler)
HttpRequestHttpRequest.send(Handler) 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.sendMultipartForm in interface HttpRequest<T>body - the bodyCopyright © 2021. All rights reserved.