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
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
    HttpClientRequestReadStreamWriteStreamStreamBase
  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
    HttpClientRequestWriteStream
  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
    HttpClientRequestWriteStream
  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
    HttpClientRequestWriteStream
  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

    Definition Classes
    HttpClientRequestReadStream
  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. * @param handler the exception handler

    returns

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

    Definition Classes
    HttpClientRequestReadStreamWriteStreamStreamBase
  20. def fetch(amount: Long): HttpClientRequest

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

    returns

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

  24. def getRawMethod(): String

    returns

    the raw value of the method this request sends

  25. def getStreamPriority(): StreamPriority

    returns

    the priority of the associated HTTP/2 stream for HTTP/2 otherwise nullsee StreamPriority

  26. def handler(handler: Handler[HttpClientResponse]): HttpClientRequest

    Definition Classes
    HttpClientRequestReadStream
  27. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  28. def headers(): MultiMap

    returns

    The HTTP headers

  29. def isChunked(): Boolean

    returns

    Is the request chunked?

  30. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  31. def method(): HttpMethod

    The HTTP method for the request.

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

    returns

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

  36. def pause(): HttpClientRequest

    Definition Classes
    HttpClientRequestReadStream
  37. 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:

    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

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

  39. def query(): String

    returns

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

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

  41. def reset(): Boolean

    Reset this stream with the error code 0.

  42. def resume(): HttpClientRequest

    Definition Classes
    HttpClientRequestReadStream
  43. 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.

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

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

  46. def setFollowRedirects(followRedirects: Boolean): HttpClientRequest
  47. 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

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

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

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

  51. 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
    HttpClientRequestWriteStream
  52. 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

  53. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  54. def toString(): String
    Definition Classes
    AnyRef → Any
  55. def uri(): String

    returns

    The URI of the request.

  56. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  57. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  58. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  59. 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

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

  61. def write(data: Buffer): HttpClientRequest

    returns

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

    Definition Classes
    HttpClientRequestWriteStream
  62. def writeCustomFrame(frame: HttpFrame): HttpClientRequest

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

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

  64. 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
    HttpClientRequestWriteStream

Inherited from ReadStream[HttpClientResponse]

Inherited from WriteStream[Buffer]

Inherited from StreamBase

Inherited from AnyRef

Inherited from Any

Ungrouped