org.vertx.scala.core.http

HttpServerResponse

final class HttpServerResponse extends Self with WriteStream

Represents a server-side HTTP response.

Instances of this class are created and associated to every instance of org.vertx.scala.core.http.HttpServerRequest that is created.

It allows the developer to control the HTTP response that is sent back to the client for a particular HTTP request. It contains methods that allow HTTP headers and trailers to be set, and for a body to be written out to the response.

It also allows files to be streamed by the kernel directly from disk to the outgoing HTTP connection, bypassing user space altogether (where supported by the underlying operating system). This is a very efficient way of serving files from the server since buffers do not have to be read one by one from the file and written to the outgoing socket.

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

Instances of this class are not thread-safe

Linear Supertypes
WriteStream, ExceptionSupport, AsJava, Self, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. HttpServerResponse
  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.HttpServerResponse

    The internal type of the Java wrapped class.

    The internal type of the Java wrapped class.

    Definition Classes
    HttpServerResponseWriteStreamExceptionSupport → AsJava

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  7. val asJava: java.core.http.HttpServerResponse

    The internal instance of the Java wrapped class.

    The internal instance of the Java wrapped class.

    Definition Classes
    HttpServerResponse → AsJava
  8. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  9. def close(): Unit

    Close the underlying TCP connection

  10. def closeHandler(handler: ⇒ Unit): HttpServerResponse

    Set a close handler for the response.

    Set a close handler for the response. This will be called if the underlying connection closes before the response is complete.

    handler

    callback when close has completed

  11. def drainHandler(handler: ⇒ Unit): HttpServerResponse.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
  12. def end(chunk: String): Unit

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

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

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

  14. def end(chunk: Buffer): Unit

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

    Same as org.vertx.scala.core.http.HttpServerResponse.end() but writes some data to the response body before ending. If the response is not chunked and no other data has been written then the Content-Length header will be automatically set

  15. def end(): Unit

    Ends the response.

    Ends the response. If no data has been written to the response body, the actual response won't get written until this method gets called.

    Once the response has ended, it cannot be used any more.

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

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

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

    Set an exception handler.

    Set an exception handler.

    Definition Classes
    ExceptionSupport
  19. def finalize(): Unit

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

    Definition Classes
    AnyRef → Any
  21. def getStatusCode: Int

    The HTTP status code of the response.

    The HTTP status code of the response. The default is 200} representing OK}.

    returns

    The status code.

  22. def getStatusMessage: String

    The HTTP status message of the response.

    The HTTP status message of the response. If this is not specified a default value will be used depending on what org.vertx.scala.core.http.HttpServerResponse.setStatusCode has been set to.

    returns

    The status message.

  23. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  24. 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.

  25. def isChunked: Boolean

    Is the response chunked?

  26. final def isInstanceOf[T0]: Boolean

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

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

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

    Definition Classes
    AnyRef
  30. def putHeader(name: String, values: String*): HttpServerResponse

    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.

  31. def putTrailer(name: String, value: String): HttpServerResponse

    Put an HTTP trailer - fluent API.

    Put an HTTP trailer - fluent API.

    name

    The trailer name

    value

    The trailer value

    returns

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

  32. def putTrailer(name: String, values: Seq[String]): HttpServerResponse

    Put an HTTP trailer - fluent API.

    Put an HTTP trailer - fluent API.

    name

    The trailer name

    values

    The trailer values

    returns

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

  33. def sendFile(filename: String, notFoundFile: String, handler: (AsyncResult[Void]) ⇒ Unit): HttpServerResponse

    Same as String) but also takes a handler that will be called when the send has completed or a failure has occurred

  34. def sendFile(filename: String, handler: (AsyncResult[Void]) ⇒ Unit): HttpServerResponse

    If chunked is true, this response will use HTTP chunked encoding, and each call to write to the body Same as org.vertx.scala.core.http.HttpServerResponse.sendFile(String) but also takes a handler that will be called when the send has completed or a failure has occurred

  35. def sendFile(filename: String): HttpServerResponse

    Tell the kernel to stream a file as specified by filename directly from disk to the outgoing connection, bypassing userspace altogether (where supported by the underlying operating system.

    Tell the kernel to stream a file as specified by filename directly from disk to the outgoing connection, bypassing userspace altogether (where supported by the underlying operating system. This is a very efficient way to serve files.

    filename

    The file to send.

    returns

    A reference to this for a fluent API.

  36. def sendFile(filename: String, notFoundFile: String): HttpServerResponse

    Same as org.vertx.scala.core.http.HttpServerResponse.sendFile(String) but also takes the path to a resource to serve if the resource is not found.

  37. def setChunked(chunked: Boolean): HttpServerResponse

    If chunked is true, this response will use HTTP chunked encoding, and each call to write to the body will correspond to a new HTTP chunk sent on the wire.

    If chunked is true, this response will use HTTP chunked encoding, and each call to write to the body will correspond to a new HTTP chunk sent on the wire.

    If chunked encoding is used the HTTP header Transfer-Encoding with a value of Chunked will be automatically inserted in the response.

    If chunked is false, this response will not use HTTP chunked encoding, and therefore if any data is written the body of the response, the total size of that data must be set in the Content-Length header before any data is written to the response body.

    An HTTP chunked response is typically used when you do not know the total size of the request body up front.

    chunked

    Sets the mode to chunked (true) or not (false).

    returns

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

  38. def setStatusCode(statusCode: Int): HttpServerResponse

    Set the status code.

    Set the status code.

    statusCode

    The status code.

    returns

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

  39. def setStatusMessage(statusMessage: String): HttpServerResponse

    Set the status message.

    Set the status message.

    statusMessage

    The status message.

    returns

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

  40. def setWriteQueueMaxSize(maxSize: Int): HttpServerResponse.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
  41. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  42. def toString(): String

    Definition Classes
    AnyRef → Any
  43. def trailers(): MultiMap

    Returns the HTTP trailers.

    Returns the HTTP trailers.

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

    returns

    The HTTP trailers.

  44. final def wait(): Unit

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

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

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  47. def wrap[X](doStuff: ⇒ X): HttpServerResponse.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
  48. def write(chunk: String, enc: String): HttpServerResponse

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

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

    chunk

    The String to write.

    enc

    The encoding to use.

    returns

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

  49. def write(chunk: String): HttpServerResponse

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

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

    chunk

    The String to write.

    returns

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

  50. def write(data: Buffer): HttpServerResponse.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
  51. 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