vertx-lang-scala-docs_2.12 3.8.0 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
- StreamPriority
- WebSocket
- WebSocketBase
- WebSocketConnectOptions
- 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. * @param 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. * @return 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`. * @param handler the handler

    returns

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

    Definition Classes
      HttpClientRequest → WriteStream
12.  def end(handler: Handler[AsyncResult[Unit]]): Unit

    Same as io.vertx.scala.core.http.HttpClientRequest#end but with an `handler` called when the operation completes

    Same as io.vertx.scala.core.http.HttpClientRequest#end but with an `handler` called when the operation completes

    Definition Classes
      HttpClientRequest → WriteStream
13.  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
14.  def end(chunk: Buffer, handler: Handler[AsyncResult[Unit]]): Unit

    Same as io.vertx.scala.core.http.HttpClientRequest#end but with an `handler` called when the operation completes

    Same as io.vertx.scala.core.http.HttpClientRequest#end but with an `handler` called when the operation completes

    Definition Classes
      HttpClientRequest → WriteStream
15.  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
16.  def end(chunk: String, enc: String, handler: Handler[AsyncResult[Unit]]): Unit

    Same as io.vertx.scala.core.http.HttpClientRequest#end but with an `handler` called when the operation completes

17.  def end(chunk: String, enc: String): Unit

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

18.  def end(chunk: String, handler: Handler[AsyncResult[Unit]]): Unit

    Same as io.vertx.scala.core.http.HttpClientRequest#end but with an `handler` called when the operation completes

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

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

20.  def endFuture(): scala.concurrent.Future[Unit]

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

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

    Definition Classes
      HttpClientRequest → WriteStream
21.  def endFuture(chunk: Buffer): scala.concurrent.Future[Unit]

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

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

    Definition Classes
      HttpClientRequest → WriteStream
22.  def endFuture(chunk: String, enc: String): scala.concurrent.Future[Unit]

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

23.  def endFuture(chunk: String): scala.concurrent.Future[Unit]

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

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

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

    Set an exception handler on the read stream.

    Set an exception handler on the read stream. * @param handler the exception handler

    returns

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

    Definition Classes
      HttpClientRequest → ReadStream → WriteStream → StreamBase
28.  def fetch(amount: Long): HttpClientRequest

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

    returns

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

32.  def getRawMethod(): String

    returns

      the raw value of the method this request sends

33.  def getStreamPriority(): StreamPriority

    returns

      the priority of the associated HTTP/2 stream for HTTP/2 otherwise `null`see StreamPriority

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

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

    returns

      The HTTP headers

37.  def isChunked(): Boolean

    returns

      Is the request chunked?

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

    The HTTP method for the request.

40.  final def ne(arg0: AnyRef): Boolean
    Definition Classes
      AnyRef
41.  final def notify(): Unit
    Definition Classes
      AnyRef
    Annotations
      @native()
42.  final def notifyAll(): Unit
    Definition Classes
      AnyRef
    Annotations
      @native()
43.  def path(): String

    returns

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

44.  def pause(): HttpClientRequest

    Definition Classes
      HttpClientRequest → ReadStream
45.  def pipe(): Pipe[HttpClientResponse]

    Pause this stream and return a to transfer the elements of this stream to a destination .

    Pause this stream and return a to transfer the elements of this stream to a destination .

    The stream will be resumed when the pipe will be wired to a `WriteStream`. * @return a pipe

    Definition Classes
      HttpClientRequest → ReadStream
46.  def pipeTo(dst: WriteStream[HttpClientResponse], handler: Handler[AsyncResult[Unit]]): Unit

    Pipe this `ReadStream` to the `WriteStream`.

    Pipe this `ReadStream` to the `WriteStream`.

    Elements emitted by this stream will be written to the write stream until this stream ends or fails.

    Once this stream has ended or failed, the write stream will be ended and the `handler` will be called with the result. * @param dst the destination write stream

    Definition Classes
      HttpClientRequest → ReadStream
47.  def pipeTo(dst: WriteStream[HttpClientResponse]): Unit

    Like io.vertx.scala.core.streams.ReadStream#pipeTo but with no completion handler.

    Like io.vertx.scala.core.streams.ReadStream#pipeTo but with no completion handler.

    Definition Classes
      HttpClientRequest → ReadStream
48.  def pipeToFuture(dst: WriteStream[HttpClientResponse]): scala.concurrent.Future[Unit]

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

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

    Definition Classes
      HttpClientRequest → ReadStream
49.  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

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

    Put an HTTP header * @param name The header name

    Put an HTTP header * @param name The header name

    value

      The header value

    returns

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

51.  def query(): String

    returns

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

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

53.  def reset(): Boolean

    Reset this stream with the error code `0`.

54.  def resume(): HttpClientRequest

    Definition Classes
      HttpClientRequest → ReadStream
55.  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.

56.  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. * @return a reference to this, so the API can be used fluently

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

    If chunked is true then the request will be set into HTTP chunked mode * @param chunked true if chunked encoding

    If chunked is true then the request will be set into HTTP chunked mode * @param chunked true if chunked encoding

    returns

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

58.  def setFollowRedirects(followRedirects: Boolean): HttpClientRequest

    Set the request to follow HTTP redirects up to HttpClientOptions.

    Set the request to follow HTTP redirects up to HttpClientOptions. * @param followRedirects `true` to follow HTTP redirects

    returns

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

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

60.  def setMaxRedirects(maxRedirects: Int): HttpClientRequest

    Set the max number of HTTP redirects this request will follow.

    Set the max number of HTTP redirects this request will follow. The default is `0` which means no redirects. * @param maxRedirects the number of HTTP redirect to follow

    returns

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

61.  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. * @param method the raw method

    returns

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

62.  def setStreamPriority(streamPriority: StreamPriority): HttpClientRequest

    Sets the priority of the associated stream.

    Sets the priority of the associated stream.

    This is not implemented for HTTP/1.x. * @param streamPriority the priority of this request's stream see StreamPriority

63.  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. * @param timeoutMs The quantity of time in milliseconds.

    returns

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

64.  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... * @param maxSize the max size of the write stream

    returns

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

    Definition Classes
      HttpClientRequest → WriteStream
65.  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

66.  final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
      AnyRef
67.  def toString(): String
    Definition Classes
      AnyRef → Any
68.  def uri(): String

    returns

      The URI of the request.

69.  final def wait(): Unit
    Definition Classes
      AnyRef
    Annotations
      @throws( ... )
70.  final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
      AnyRef
    Annotations
      @throws( ... )
71.  final def wait(arg0: Long): Unit
    Definition Classes
      AnyRef
    Annotations
      @native() @throws( ... )
72.  def write(chunk: String, enc: String, handler: Handler[AsyncResult[Unit]]): HttpClientRequest

    Same as io.vertx.scala.core.http.HttpClientRequest#write but with an `handler` called when the operation completes

73.  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`. * @return @return a reference to this, so the API can be used fluently

74.  def write(chunk: String, handler: Handler[AsyncResult[Unit]]): HttpClientRequest

    Same as io.vertx.scala.core.http.HttpClientRequest#write but with an `handler` called when the operation completes

75.  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. * @return @return a reference to this, so the API can be used fluently

76.  def write(data: Buffer, handler: Handler[AsyncResult[Unit]]): HttpClientRequest

    Same as io.vertx.scala.core.http.HttpClientRequest#write but with an `handler` called when the operation completes

    Same as io.vertx.scala.core.http.HttpClientRequest#write but with an `handler` called when the operation completes

    Definition Classes
      HttpClientRequest → WriteStream
77.  def write(data: Buffer): HttpClientRequest

    returns

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

    Definition Classes
      HttpClientRequest → WriteStream
78.  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. * @param frame the frame to write

79.  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. * @param 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

80.  def writeFuture(chunk: String, enc: String): scala.concurrent.Future[Unit]

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

81.  def writeFuture(chunk: String): scala.concurrent.Future[Unit]

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

82.  def writeFuture(data: Buffer): scala.concurrent.Future[Unit]

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

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

    Definition Classes
      HttpClientRequest → WriteStream
83.  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 * @return true if write queue is full

    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 * @return 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