vertx-lang-scala-docs_2.12 3.6.3 API < Back
 

# Packages

-  package root
  Definition Classes
    root
-  package io
  Definition Classes
    root
-  package vertx
  Definition Classes
    io
-  package scala
  Definition Classes
    vertx
-  package ext
  Definition Classes
    scala
-  package web
  Definition Classes
    ext
-  package client
  Definition Classes
    web
-  package predicate
  Definition Classes
    client
- HttpRequest
- HttpResponse
- WebClient
- WebClientOptions

c

io.vertx.scala.ext.web.client

# HttpRequest 

###
Companion object HttpRequest

#### 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 .

Linear Supertypes
AnyRef, Any
 
Ordering

1. Alphabetic
2. By Inheritance

Inherited

1. HttpRequest
2. AnyRef
3. Any

1. Hide All
2. Show All

Visibility

1. Public
2. All

### Instance Constructors

1.  new HttpRequest(_asJava: AnyRef)(implicit arg0: scala.reflect.api.JavaUniverse.TypeTag[T])

### Value Members

1.  final def !=(arg0: Any): Boolean
   Definition Classes
     AnyRef → Any
2.  final def ##(): Int
   Definition Classes
     AnyRef → Any
3.  final def ==(arg0: Any): Boolean
   Definition Classes
     AnyRef → Any
4.  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

5.  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

6.  final def asInstanceOf[T0]: T0
   Definition Classes
     Any
7.  def asJava: AnyRef
8.  def basicAuthentication(id: Buffer, password: Buffer): HttpRequest[T]

   Configure the request to perform basic access authentication.

   Configure the request to perform basic access authentication.

   In basic HTTP authentication, a request contains a header field of the form 'Authorization: Basic <credentials>', where credentials is the base64 encoding of id and password joined by a colon. * @param id the id

   password

     the password

   returns

     a reference to this, so the API can be used fluently

9.  def basicAuthentication(id: String, password: String): HttpRequest[T]

   Configure the request to perform basic access authentication.

   Configure the request to perform basic access authentication.

   In basic HTTP authentication, a request contains a header field of the form 'Authorization: Basic <credentials>', where credentials is the base64 encoding of id and password joined by a colon. * @param id the id

   password

     the password

   returns

     a reference to this, so the API can be used fluently

10.  def bearerTokenAuthentication(bearerToken: String): HttpRequest[T]

    Configure the request to perform bearer token authentication.

    Configure the request to perform bearer token authentication.

    In OAuth 2.0, a request contains a header field of the form 'Authorization: Bearer <bearerToken>', where bearerToken is the bearer token issued by an authorization server to access protected resources. * @param bearerToken the bearer token

    returns

      a reference to this, so the API can be used fluently

11.  def clone(): AnyRef
    Attributes
      protected[java.lang]
    Definition Classes
      AnyRef
    Annotations
      @native() @throws( ... )
12.  def copy(): HttpRequest[T]

    Copy this request * @return a copy of this request

13.  final def eq(arg0: AnyRef): Boolean
    Definition Classes
      AnyRef
14.  def equals(arg0: Any): Boolean
    Definition Classes
      AnyRef → Any
15.  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

16.  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

17.  def finalize(): Unit
    Attributes
      protected[java.lang]
    Definition Classes
      AnyRef
    Annotations
      @throws( classOf[java.lang.Throwable] )
18.  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

19.  final def getClass(): Class[_]
    Definition Classes
      AnyRef → Any
    Annotations
      @native()
20.  def hashCode(): Int
    Definition Classes
      AnyRef → Any
    Annotations
      @native()
21.  def headers(): MultiMap

    returns

      The HTTP headers

22.  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

23.  final def isInstanceOf[T0]: Boolean
    Definition Classes
      Any
24.  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

25.  final def ne(arg0: AnyRef): Boolean
    Definition Classes
      AnyRef
26.  final def notify(): Unit
    Definition Classes
      AnyRef
    Annotations
      @native()
27.  final def notifyAll(): Unit
    Definition Classes
      AnyRef
    Annotations
      @native()
28.  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

29.  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

30.  def queryParams(): MultiMap

    Return the current query parameters.

    Return the current query parameters. * @return the current query parameters

31.  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.

32.  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

33.  def sendBufferFuture(body: Buffer): Future[HttpResponse[T]]

    Like sendBuffer but returns a scala.concurrent.Future instead of taking an AsyncResultHandler.

34.  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 to `application/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 to `application/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

35.  def sendFormFuture(body: MultiMap): Future[HttpResponse[T]]

    Like sendForm but returns a scala.concurrent.Future instead of taking an AsyncResultHandler.

36.  def sendFuture(): Future[HttpResponse[T]]

    Like send but returns a scala.concurrent.Future instead of taking an AsyncResultHandler.

37.  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 to `application/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 to `application/json`. * @param body the body

38.  def sendJsonFuture(body: AnyRef): Future[HttpResponse[T]]

    Like sendJson but returns a scala.concurrent.Future instead of taking an AsyncResultHandler.

39.  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 to `application/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 to `application/json`. * @param body the body

40.  def sendJsonObjectFuture(body: JsonObject): Future[HttpResponse[T]]

    Like sendJsonObject but returns a scala.concurrent.Future instead of taking an AsyncResultHandler.

41.  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 to `multipart/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 to `multipart/form-data`. You may use this method to send attributes and upload files. * @param body the body

42.  def sendMultipartFormFuture(body: MultipartForm): Future[HttpResponse[T]]

    Like sendMultipartForm but returns a scala.concurrent.Future instead of taking an AsyncResultHandler.

43.  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

44.  def sendStreamFuture(body: ReadStream[Buffer]): Future[HttpResponse[T]]

    Like sendStream but returns a scala.concurrent.Future instead of taking an AsyncResultHandler.

45.  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

46.  def ssl(value: Boolean): HttpRequest[T]
47.  final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
      AnyRef
48.  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

49.  def toString(): String
    Definition Classes
      AnyRef → Any
50.  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

51.  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

52.  final def wait(): Unit
    Definition Classes
      AnyRef
    Annotations
      @throws( ... )
53.  final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
      AnyRef
    Annotations
      @throws( ... )
54.  final def wait(arg0: Long): Unit
    Definition Classes
      AnyRef
    Annotations
      @native() @throws( ... )

### Inherited from AnyRef

### Inherited from Any

### Ungrouped