org.vertx.scala.core.http

HttpClientRequest

final class HttpClientRequest extends Self with WriteStream

Represents a client-side HTTP request.

Instances are created by an org.vertx.scala.core.http.HttpClient instance, via one of the methods corresponding to the specific HTTP methods, or the generic org.vertx.scala.core.http.HttpClient.request method.

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, the end() method should be called.

Nothing is actually sent until the request has been internally assigned an HTTP connection. The org.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 actually sent either when the 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 org.vertx.java.core.streams.WriteStream so it can be used with org.vertx.java.core.streams.Pump to pump data with flow control.

An example of using this class is as follows:


val req = httpClient.post("/some-url", { (response: HttpClientResponse) =>
  println("Got response: " + response.statusCode)
})

req.headers().put("some-header", "hello")
    .put("Content-Length", 5)
    .write(new Buffer(Array[Byte](1, 2, 3, 4, 5)))
    .write(new Buffer(Array[Byte](6, 7, 8, 9, 10)))
    .end()

Instances of HttpClientRequest are not thread-safe.

Linear Supertypes
WriteStream, ExceptionSupport, AsJava, Self, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. HttpClientRequest
  2. WriteStream
  3. ExceptionSupport
  4. AsJava
  5. Self
  6. AnyRef
  7. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Type Members

  1. type J = java.core.http.HttpClientRequest

    The internal type of the Java wrapped class.

    The internal type of the Java wrapped class.

    Definition Classes
    HttpClientRequestWriteStreamExceptionSupport → AsJava

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. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  5. val asJava: java.core.http.HttpClientRequest

    The internal instance of the Java wrapped class.

    The internal instance of the Java wrapped class.

    Definition Classes
    HttpClientRequest → AsJava
  6. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  7. def continueHandler(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 org.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 multiple method calls can be chained.

  8. def drainHandler(handler: ⇒ Unit): HttpClientRequest.this.type

    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 has been reduced to maxSize / 2. See org.vertx.scala.core.streams.Pump for an example of this being used.

    Definition Classes
    WriteStream
  9. def end(): Unit

    Ends the request.

    Ends the request. If no data has been written to the request body, and org.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, and if keep alive is true the underlying connection will be returned to the org.vertx.scala.core.http.HttpClient pool so it can be assigned to another request.

  10. def end(chunk: Buffer): Unit

    Same as org.vertx.scala.core.http.HttpClientRequest.end() but writes some data to the request body before ending.

    Same as org.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.

  11. def end(chunk: String, enc: String): Unit

    Same as org.vertx.scala.core.http.HttpClientRequest.end(Buffer) but writes a String with the specified encoding.

  12. def end(chunk: String): Unit

    Same as org.vertx.scala.core.http.HttpClientRequest.end(Buffer) but writes a String with the default encoding.

  13. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  14. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  15. def exceptionHandler(handler: (Throwable) ⇒ Unit): HttpClientRequest.this.type

    Set an exception handler.

    Set an exception handler.

    Definition Classes
    ExceptionSupport
  16. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  17. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  18. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  19. def headers(): MultiMap

    Returns the HTTP headers.

    Returns the HTTP headers.

    This method converts a Java collection into a Scala collection every time it gets called, so use it sensibly.

    returns

    The HTTP headers.

  20. def isChunked: Boolean

    Checks whether the request is chunked.

    Checks whether the request is chunked.

    returns

    True if the request is chunked.

  21. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  22. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  23. final def notify(): Unit

    Definition Classes
    AnyRef
  24. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  25. def putHeader(name: String, values: String*): HttpClientRequest

    Put an HTTP header - fluent API.

    Put an HTTP header - fluent API.

    name

    The header name

    values

    The header values

    returns

    A reference to this, so multiple method calls can be chained.

  26. def sendHead(): HttpClientRequest

    Forces the head of the request to be written before org.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 org.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 org.vertx.scala.core.http.HttpClientRequest.continueHandler(org.vertx.java.core.Handler) for more information.

    returns

    A reference to this, so multiple method calls can be chained.

  27. 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 you want the request to be in chunked mode.

    returns

    A reference to this, so multiple method calls can be chained.

  28. def setTimeout(timeoutMs: Long): HttpClientRequest

    Sets the amount of time after which if a response is not received TimeoutException() will be sent to the exception handler of this request.

    Sets the amount of time after which if a response is not received TimeoutException() will be sent to the exception handler of this request. 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 multiple method calls can be chained.

  29. def setWriteQueueMaxSize(maxSize: Int): HttpClientRequest.this.type

    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 bytes in the write queue. This is used as an indicator by classes such as Pump to provide flow control.

    Definition Classes
    WriteStream
  30. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  31. def toString(): String

    Definition Classes
    AnyRef → Any
  32. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  33. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  34. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  35. def wrap[X](doStuff: ⇒ X): HttpClientRequest.this.type

    Helper method wrapping invocations and returning the Scala type, once again to help provide fluent return types

    Helper method wrapping invocations and returning the Scala type, once again to help provide fluent return types

    Attributes
    protected[this]
    Definition Classes
    Self
  36. def write(chunk: String, enc: String): HttpClientRequest

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

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

    returns

    A reference to this, so multiple method calls can be chained.

  37. def write(chunk: String): HttpClientRequest

    Write a java.lang.String to the request body, encoded in UTF-8.

    Write a java.lang.String to the request body, encoded in UTF-8.

    returns

    A reference to this, so multiple method calls can be chained.

  38. def write(data: Buffer): HttpClientRequest.this.type

    Write some data to the stream.

    Write some data to the stream. The data is put on an internal write queue, and the write actually happens asynchronously. To avoid running out of memory by putting too much on the write queue, check the org.vertx.scala.core.streams.WriteStream.writeQueueFull() method before writing. This is done automatically if using a org.vertx.scala.core.streams.Pump.

    Definition Classes
    WriteStream
  39. def writeQueueFull(): Boolean

    This will return true if there are more bytes in the write queue than the value set using org.vertx.scala.core.streams.WriteStream.setWriteQueueMaxSize()

    This will return true if there are more bytes in the write queue than the value set using org.vertx.scala.core.streams.WriteStream.setWriteQueueMaxSize()

    Definition Classes
    WriteStream

Inherited from WriteStream

Inherited from ExceptionSupport

Inherited from AsJava

Inherited from Self

Inherited from AnyRef

Inherited from Any

Ungrouped