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

# Packages

-  package root
  Definition Classes
    root
-  package io
  Definition Classes
    root
-  package vertx
  Definition Classes
    io
-  package scala
  Definition Classes
    vertx
-  package core
  Definition Classes
    scala
-  package http
  Definition Classes
    core
- GoAway
- Http2Settings
- HttpClient
- HttpClientOptions
- HttpClientRequest
- HttpClientResponse
- HttpConnection
- HttpFrame
- HttpServer
- HttpServerFileUpload
- HttpServerOptions
- HttpServerRequest
- HttpServerResponse
- RequestOptions
- ServerWebSocket
- WebSocket
- WebSocketBase
- WebSocketFrame

c

io.vertx.scala.core.http

# HttpClientRequest 

###
Companion object HttpClientRequest

#### class HttpClientRequest extends WriteStream[Buffer] with ReadStream[HttpClientResponse]

Represents a client-side HTTP request.

Instances are created by an io.vertx.scala.core.http.HttpClient instance, via one of the methods corresponding to the specific HTTP methods, or the generic request methods. On creation the request will not have been written to the wire.

Once a request has been obtained, headers can be set on it, and data can be written to its body if required. Once you are ready to send the request, one of the io.vertx.scala.core.http.HttpClientRequest#end methods should be called.

Nothing is actually sent until the request has been internally assigned an HTTP connection.

The io.vertx.scala.core.http.HttpClient instance will return an instance of this class immediately, even if there are no HTTP connections available in the pool. Any requests sent before a connection is assigned will be queued internally and actually sent when an HTTP connection becomes available from the pool.

The headers of the request are queued for writing either when the io.vertx.scala.core.http.HttpClientRequest#end method is called, or, when the first part of the body is written, whichever occurs first.

This class supports both chunked and non-chunked HTTP.

It implements io.vertx.scala.core.streams.WriteStream so it can be used with io.vertx.scala.core.streams.Pump to pump data with flow control.

An example of using this class is as follows:

Linear Supertypes
ReadStream[HttpClientResponse], WriteStream[Buffer], StreamBase, AnyRef, Any
 
Ordering

1. Alphabetic
2. By Inheritance

Inherited

1. HttpClientRequest
2. ReadStream
3. WriteStream
4. StreamBase
5. AnyRef
6. Any

1. Hide All
2. Show All

Visibility

1. Public
2. All

### Instance Constructors

1.  new HttpClientRequest(_asJava: AnyRef)

### 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 absoluteURI(): String

   returns

     the absolute URI corresponding to the the HTTP request

5.  final def asInstanceOf[T0]: T0
   Definition Classes
     Any
6.  def asJava: AnyRef
   Definition Classes
     HttpClientRequest → ReadStream → WriteStream → StreamBase
7.  def clone(): AnyRef
   Attributes
     protected[java.lang]
   Definition Classes
     AnyRef
   Annotations
     @native() @throws( ... )
8.  def connection(): HttpConnection

   returns

     the HttpConnection associated with this request

9.  def connectionHandler(handler: Handler[HttpConnection]): HttpClientRequest

   Set a connection handler called when an HTTP connection has been established.

   Set a connection handler called when an HTTP connection has been established.

   handler

     the handler

   returns

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

10.  def continueHandler(handler: Handler[Unit]): HttpClientRequest

    If you send an HTTP request with the header `Expect` set to the value `100-continue` and the server responds with an interim HTTP response with a status code of `100` and a continue handler has been set using this method, then the `handler` will be called.

    If you send an HTTP request with the header `Expect` set to the value `100-continue` and the server responds with an interim HTTP response with a status code of `100` and a continue handler has been set using this method, then the `handler` will be called.

    You can then continue to write data to the request body and later end it. This is normally used in conjunction with the io.vertx.scala.core.http.HttpClientRequest#sendHead method to force the request header to be written before the request has ended.

    returns

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

11.  def drainHandler(handler: Handler[Unit]): HttpClientRequest

    Set a drain handler on the stream.

    Set a drain handler on the stream. If the write queue is full, then the handler will be called when the write queue is ready to accept buffers again. See io.vertx.scala.core.streams.Pump for an example of this being used.

    The stream implementation defines when the drain handler, for example it could be when the queue size has been reduced to `maxSize / 2`.

    handler

      the handler

    returns

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

    Definition Classes
      HttpClientRequest → WriteStream
12.  def end(): Unit

    Ends the request.

    Ends the request. If no data has been written to the request body, and io.vertx.scala.core.http.HttpClientRequest#sendHead has not been called then the actual request won't get written until this method gets called.

    Once the request has ended, it cannot be used any more,

    Definition Classes
      HttpClientRequest → WriteStream
13.  def end(chunk: Buffer): Unit

    Same as io.vertx.scala.core.http.HttpClientRequest#end but writes some data to the request body before ending.

    Same as io.vertx.scala.core.http.HttpClientRequest#end but writes some data to the request body before ending. If the request is not chunked and no other data has been written then the `Content-Length` header will be automatically set

    Definition Classes
      HttpClientRequest → WriteStream
14.  def end(chunk: String, enc: String): Unit

    Same as io.vertx.scala.core.http.HttpClientRequest#end but writes a String with the specified encoding

15.  def end(chunk: String): Unit

    Same as io.vertx.scala.core.http.HttpClientRequest#end but writes a String in UTF-8 encoding

16.  def endHandler(endHandler: Handler[Unit]): HttpClientRequest

    Set an end handler.

    Set an end handler. Once the stream has ended, and there is no more data to be read, this handler will be called.

    returns

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

    Definition Classes
      HttpClientRequest → ReadStream
17.  final def eq(arg0: AnyRef): Boolean
    Definition Classes
      AnyRef
18.  def equals(arg0: Any): Boolean
    Definition Classes
      AnyRef → Any
19.  def exceptionHandler(handler: Handler[Throwable]): HttpClientRequest

    Set an exception handler on the read stream.

    Set an exception handler on the read stream.

    handler

      the exception handler

    returns

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

    Definition Classes
      HttpClientRequest → ReadStream → WriteStream → StreamBase
20.  def finalize(): Unit
    Attributes
      protected[java.lang]
    Definition Classes
      AnyRef
    Annotations
      @throws( classOf[java.lang.Throwable] )
21.  final def getClass(): Class[_]
    Definition Classes
      AnyRef → Any
    Annotations
      @native()
22.  def getHost(): String

    returns

      the request host. For HTTP/2 it returns the `:authority` pseudo header otherwise it returns the `Host` header

23.  def getRawMethod(): String

    returns

      the raw value of the method this request sends

24.  def handler(handler: Handler[HttpClientResponse]): HttpClientRequest

    Set a data handler.

    Set a data handler. As data is read, the handler will be called with the data.

    returns

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

    Definition Classes
      HttpClientRequest → ReadStream
25.  def hashCode(): Int
    Definition Classes
      AnyRef → Any
    Annotations
      @native()
26.  def headers(): MultiMap

    returns

      The HTTP headers

27.  def isChunked(): Boolean

    returns

      Is the request chunked?

28.  final def isInstanceOf[T0]: Boolean
    Definition Classes
      Any
29.  def method(): HttpMethod

    The HTTP method for the request.

30.  final def ne(arg0: AnyRef): Boolean
    Definition Classes
      AnyRef
31.  final def notify(): Unit
    Definition Classes
      AnyRef
    Annotations
      @native()
32.  final def notifyAll(): Unit
    Definition Classes
      AnyRef
    Annotations
      @native()
33.  def path(): String

    returns

      The path part of the uri. For example /somepath/somemorepath/someresource.foo

34.  def pause(): HttpClientRequest

    Pause the `ReadSupport`.

    Pause the `ReadSupport`. While it's paused, no data will be sent to the `dataHandler`

    returns

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

    Definition Classes
      HttpClientRequest → ReadStream
35.  def pushHandler(handler: Handler[HttpClientRequest]): HttpClientRequest

    Set a push handler for this request.

    Set a push handler for this request.

    The handler is called when the client receives a push promise from the server. The handler can be called multiple times, for each push promise.

    The handler is called with a read-only io.vertx.scala.core.http.HttpClientRequest, the following methods can be called:

    - io.vertx.scala.core.http.HttpClientRequest#method
    - io.vertx.scala.core.http.HttpClientRequest#uri
    - io.vertx.scala.core.http.HttpClientRequest#headers
    - io.vertx.scala.core.http.HttpClientRequest#getHost

    In addition the handler should call the io.vertx.scala.core.http.HttpClientRequest#handler method to set an handler to process the response.

    handler

      the handler

    returns

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

36.  def putHeader(name: String, value: String): HttpClientRequest

    Put an HTTP header

    Put an HTTP header

    name

      The header name

    value

      The header value

    returns

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

37.  def query(): String

    returns

      the query part of the uri. For example someparam=32&someotherparam=x

38.  def reset(code: Long): Boolean

    Reset this request:

    Reset this request:

    - for HTTP/2, this performs send an HTTP/2 reset frame with the specified error `code`
    - for HTTP/1.x, this closes the connection when the current request is inflight

    When the request has not yet been sent, the request will be aborted and false is returned as indicator.

    code

      the error code

    returns

      true when reset has been performed

39.  def reset(): Boolean

    Reset this stream with the error code `0`.

40.  def resume(): HttpClientRequest

    Resume reading.

    Resume reading. If the `ReadSupport` has been paused, reading will recommence on it.

    returns

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

    Definition Classes
      HttpClientRequest → ReadStream
41.  def sendHead(completionHandler: Handler[HttpVersion]): HttpClientRequest

    Like io.vertx.scala.core.http.HttpClientRequest#sendHead but with an handler after headers have been sent.

    Like io.vertx.scala.core.http.HttpClientRequest#sendHead but with an handler after headers have been sent. The handler will be called with the io.vertx.core.http.HttpVersion if it can be determined or null otherwise.

42.  def sendHead(): HttpClientRequest

    Forces the head of the request to be written before io.vertx.scala.core.http.HttpClientRequest#end is called on the request or any data is written to it.

    Forces the head of the request to be written before io.vertx.scala.core.http.HttpClientRequest#end is called on the request or any data is written to it.

    This is normally used to implement HTTP 100-continue handling, see for more information.

    returns

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

43.  def setChunked(chunked: Boolean): HttpClientRequest

    If chunked is true then the request will be set into HTTP chunked mode

    If chunked is true then the request will be set into HTTP chunked mode

    chunked

      true if chunked encoding

    returns

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

44.  def setFollowRedirects(followRedirects: Boolean): HttpClientRequest
45.  def setHost(host: String): HttpClientRequest

    Set the request host.

    Set the request host.

    For HTTP/2 it sets the pseudo header otherwise it sets the header

46.  def setRawMethod(method: String): HttpClientRequest

    Set the value the method to send when the method is used.

    Set the value the method to send when the method is used.

    method

      the raw method

    returns

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

47.  def setTimeout(timeoutMs: Long): HttpClientRequest

    Set's the amount of time after which if the request does not return any data within the timeout period an TimeoutException will be passed to the exception handler (if provided) and the request will be closed.

    Set's the amount of time after which if the request does not return any data within the timeout period an TimeoutException will be passed to the exception handler (if provided) and the request will be closed.

    Calling this method more than once has the effect of canceling any existing timeout and starting the timeout from scratch.

    timeoutMs

      The quantity of time in milliseconds.

    returns

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

48.  def setWriteQueueMaxSize(maxSize: Int): HttpClientRequest

    Set the maximum size of the write queue to `maxSize`.

    Set the maximum size of the write queue to `maxSize`. You will still be able to write to the stream even if there is more than `maxSize` items in the write queue. This is used as an indicator by classes such as `Pump` to provide flow control.

    The value is defined by the implementation of the stream, e.g in bytes for a io.vertx.scala.core.net.NetSocket, the number of io.vertx.scala.core.eventbus.Message for a io.vertx.scala.core.eventbus.MessageProducer, etc...

    maxSize

      the max size of the write stream

    returns

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

    Definition Classes
      HttpClientRequest → WriteStream
49.  def streamId(): Int

    returns

      the id of the stream of this response, `-1` when it is not yet determined, i.e the request has not been yet sent or it is not supported HTTP/1.x

50.  final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
      AnyRef
51.  def toString(): String
    Definition Classes
      AnyRef → Any
52.  def uri(): String

    returns

      The URI of the request.

53.  final def wait(): Unit
    Definition Classes
      AnyRef
    Annotations
      @throws( ... )
54.  final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
      AnyRef
    Annotations
      @throws( ... )
55.  final def wait(arg0: Long): Unit
    Definition Classes
      AnyRef
    Annotations
      @native() @throws( ... )
56.  def write(chunk: String, enc: String): HttpClientRequest

    Write a String to the request body, encoded using the encoding `enc`.

    Write a String to the request body, encoded using the encoding `enc`.

    returns

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

57.  def write(chunk: String): HttpClientRequest

    Write a String to the request body, encoded as UTF-8.

    Write a String to the request body, encoded as UTF-8.

    returns

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

58.  def write(data: Buffer): HttpClientRequest

    data

      the data to write

    returns

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

    Definition Classes
      HttpClientRequest → WriteStream
59.  def writeCustomFrame(frame: HttpFrame): HttpClientRequest

    Like io.vertx.scala.core.http.HttpClientRequest#writeCustomFrame but with an io.vertx.scala.core.http.HttpFrame.

    Like io.vertx.scala.core.http.HttpClientRequest#writeCustomFrame but with an io.vertx.scala.core.http.HttpFrame.

    frame

      the frame to write

60.  def writeCustomFrame(type: Int, flags: Int, payload: Buffer): HttpClientRequest

    Write an HTTP/2 frame to the request, allowing to extend the HTTP/2 protocol.

    Write an HTTP/2 frame to the request, allowing to extend the HTTP/2 protocol.

    The frame is sent immediatly and is not subject to flow control.

    This method must be called after the request headers have been sent and only for the protocol HTTP/2. The io.vertx.scala.core.http.HttpClientRequest#sendHead should be used for this purpose.

    type

      the 8-bit frame type

    flags

      the 8-bit frame flags

    payload

      the frame payload

    returns

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

61.  def writeQueueFull(): Boolean

    This will return `true` if there are more bytes in the write queue than the value set using io.vertx.scala.core.http.HttpClientRequest#setWriteQueueMaxSize

    This will return `true` if there are more bytes in the write queue than the value set using io.vertx.scala.core.http.HttpClientRequest#setWriteQueueMaxSize

    returns

      true if write queue is full

    Definition Classes
      HttpClientRequest → WriteStream

### Inherited from ReadStream[HttpClientResponse]

### Inherited from WriteStream[Buffer]

### Inherited from StreamBase

### Inherited from AnyRef

### Inherited from Any

### Ungrouped