class HttpRequest[T] extends AnyRef
A client-side HTTP request.
Instances are created by an io.vertx.scala.ext.web.client.WebClient instance, via one of the methods corresponding to the specific HTTP methods such as io.vertx.scala.ext.web.client.WebClient#get, 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
- io.vertx.scala.ext.web.client.HttpRequest#send
- io.vertx.scala.ext.web.client.HttpRequest#sendStream
- io.vertx.scala.ext.web.client.HttpRequest#sendJson ()}
- io.vertx.scala.ext.web.client.HttpRequest#sendForm
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 io.vertx.scala.ext.web.client.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 .
- Alphabetic
- By Inheritance
- HttpRequest
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
- new HttpRequest(_asJava: AnyRef)(implicit arg0: scala.reflect.api.JavaUniverse.TypeTag[T])
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
addQueryParam(paramName: String, paramValue: String): HttpRequest[T]
Add a query parameter to the request.
Add a query parameter to the request. * @param paramName the param name
- paramValue
the param value
- returns
a reference to this, so the API can be used fluently
-
def
as[U](responseCodec: BodyCodec[U])(implicit arg0: scala.reflect.api.JavaUniverse.TypeTag[U]): HttpRequest[U]
Configure the request to decode the response with the
responseCodec
.Configure the request to decode the response with the
responseCodec
. * @param responseCodec the response codec- returns
a reference to this, so the API can be used fluently
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
- def asJava: AnyRef
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
def
copy(): HttpRequest[T]
Copy this request * @return a copy of this request
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
expect(predicate: ResponsePredicate): HttpRequest[T]
Add an expectation that the response is valid according to the provided
predicate
.Add an expectation that the response is valid according to the provided
predicate
.Multiple predicates can be added. * @param predicate the predicate
- returns
a reference to this, so the API can be used fluently
-
def
expect(predicate: (HttpResponse[Unit]) ⇒ ResponsePredicateResult): HttpRequest[T]
Add an expectation that the response is valid according to the provided
predicate
.Add an expectation that the response is valid according to the provided
predicate
.Multiple predicates can be added. * @param predicate the predicate
- returns
a reference to this, so the API can be used fluently
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
followRedirects(value: Boolean): HttpRequest[T]
Set wether or not to follow the directs for the request.
Set wether or not to follow the directs for the request. * @param value true if redirections should be followed
- returns
a reference to this, so the API can be used fluently
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
headers(): MultiMap
- returns
The HTTP headers
-
def
host(value: String): HttpRequest[T]
Configure the request to use a new host
value
.Configure the request to use a new host
value
. * @return a reference to this, so the API can be used fluently -
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
method(value: HttpMethod): HttpRequest[T]
Configure the request to use a new method
value
.Configure the request to use a new method
value
. * @return a reference to this, so the API can be used fluently -
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
port(value: Int): HttpRequest[T]
Configure the request to use a new port
value
.Configure the request to use a new port
value
. * @return a reference to this, so the API can be used fluently -
def
putHeader(name: String, value: String): HttpRequest[T]
Configure the request to add a new HTTP header.
Configure the request to add a new HTTP header. * @param name the header name
- value
the header value
- returns
a reference to this, so the API can be used fluently
-
def
queryParams(): MultiMap
Return the current query parameters.
Return the current query parameters. * @return the current query parameters
-
def
send(handler: Handler[AsyncResult[HttpResponse[T]]]): Unit
Send a request, the
handler
will receive the response as an io.vertx.scala.ext.web.client.HttpResponse. -
def
sendBuffer(body: Buffer, handler: Handler[AsyncResult[HttpResponse[T]]]): Unit
Like io.vertx.scala.ext.web.client.HttpRequest#send but with an HTTP request
body
buffer.Like io.vertx.scala.ext.web.client.HttpRequest#send but with an HTTP request
body
buffer. * @param body the body -
def
sendBufferFuture(body: Buffer): Future[HttpResponse[T]]
Like sendBuffer but returns a scala.concurrent.Future instead of taking an AsyncResultHandler.
-
def
sendForm(body: MultiMap, handler: Handler[AsyncResult[HttpResponse[T]]]): Unit
Like io.vertx.scala.ext.web.client.HttpRequest#send but with an HTTP request
body
multimap encoded as form and the content type set toapplication/x-www-form-urlencoded
.Like io.vertx.scala.ext.web.client.HttpRequest#send but with an HTTP request
body
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. * @param body the body -
def
sendFormFuture(body: MultiMap): Future[HttpResponse[T]]
Like sendForm but returns a scala.concurrent.Future instead of taking an AsyncResultHandler.
-
def
sendFuture(): Future[HttpResponse[T]]
Like send but returns a scala.concurrent.Future instead of taking an AsyncResultHandler.
-
def
sendJson(body: AnyRef, handler: Handler[AsyncResult[HttpResponse[T]]]): Unit
Like io.vertx.scala.ext.web.client.HttpRequest#send but with an HTTP request
body
object encoded as json and the content type set toapplication/json
.Like io.vertx.scala.ext.web.client.HttpRequest#send but with an HTTP request
body
object encoded as json and the content type set toapplication/json
. * @param body the body -
def
sendJsonFuture(body: AnyRef): Future[HttpResponse[T]]
Like sendJson but returns a scala.concurrent.Future instead of taking an AsyncResultHandler.
-
def
sendJsonObject(body: JsonObject, handler: Handler[AsyncResult[HttpResponse[T]]]): Unit
Like io.vertx.scala.ext.web.client.HttpRequest#send but with an HTTP request
body
object encoded as json and the content type set toapplication/json
.Like io.vertx.scala.ext.web.client.HttpRequest#send but with an HTTP request
body
object encoded as json and the content type set toapplication/json
. * @param body the body -
def
sendJsonObjectFuture(body: JsonObject): Future[HttpResponse[T]]
Like sendJsonObject but returns a scala.concurrent.Future instead of taking an AsyncResultHandler.
-
def
sendMultipartForm(body: MultipartForm, handler: Handler[AsyncResult[HttpResponse[T]]]): Unit
Like io.vertx.scala.ext.web.client.HttpRequest#send but with an HTTP request
body
multimap encoded as form and the content type set tomultipart/form-data
.Like io.vertx.scala.ext.web.client.HttpRequest#send but with an HTTP request
body
multimap encoded as form and the content type set tomultipart/form-data
. You may use this method to send attributes and upload files. * @param body the body -
def
sendMultipartFormFuture(body: MultipartForm): Future[HttpResponse[T]]
Like sendMultipartForm but returns a scala.concurrent.Future instead of taking an AsyncResultHandler.
-
def
sendStream(body: ReadStream[Buffer], handler: Handler[AsyncResult[HttpResponse[T]]]): Unit
Like io.vertx.scala.ext.web.client.HttpRequest#send but with an HTTP request
body
stream.Like io.vertx.scala.ext.web.client.HttpRequest#send but with an HTTP request
body
stream. * @param body the body -
def
sendStreamFuture(body: ReadStream[Buffer]): Future[HttpResponse[T]]
Like sendStream but returns a scala.concurrent.Future instead of taking an AsyncResultHandler.
-
def
setQueryParam(paramName: String, paramValue: String): HttpRequest[T]
Set a query parameter to the request.
Set a query parameter to the request. * @param paramName the param name
- paramValue
the param value
- returns
a reference to this, so the API can be used fluently
- def ssl(value: Boolean): HttpRequest[T]
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
timeout(value: Long): HttpRequest[T]
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.
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.
Setting zero or a negative
value
disables the timeout. * @param value The quantity of time in milliseconds.- returns
a reference to this, so the API can be used fluently
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
def
uri(value: String): HttpRequest[T]
Configure the request to use a new request URI
value
.Configure the request to use a new request URI
value
.When the uri has query parameters, they are set in the io.vertx.scala.ext.web.client.HttpRequest#queryParams multimap, overwritting any parameters previously set. * @return a reference to this, so the API can be used fluently
-
def
virtualHost(value: String): HttpRequest[T]
Configure the request to use a virtual host
value
.Configure the request to use a virtual host
value
.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. * @return a reference to this, so the API can be used fluently
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )