org.vertx.java.core.http.impl

## Class DefaultHttpServerResponse

- java.lang.Object
- - org.vertx.java.core.http.HttpServerResponse
  - - org.vertx.java.core.http.impl.DefaultHttpServerResponse

All Implemented Interfaces:
  WriteStream

    public class DefaultHttpServerResponse
    extends HttpServerResponse

### Field Summary

### Fields inherited from class org.vertx.java.core.http.HttpServerResponse

`statusCode, statusMessage`

### Method Summary

Methods
`void` `close()` Close the underlying TCP connection
`void` `closeHandler(Handler<java.lang.Void> handler)` Set a close handler for the response.
`void` `drainHandler(Handler<java.lang.Void> handler)` Set a drain handler on the stream.
`void` `end()` Ends the response.
`void` `end(Buffer chunk)` Same as `HttpServerResponse.end()` but writes some data to the response body before ending.
`void` `end(java.lang.String chunk)` Same as `HttpServerResponse.end(Buffer)` but writes a String with the default encoding before ending the response.
`void` `end(java.lang.String chunk, java.lang.String enc)` Same as `HttpServerResponse.end(Buffer)` but writes a String with the specified encoding before ending the response.
`void` `exceptionHandler(Handler<java.lang.Exception> handler)` Set an exception handler on the stream
`java.util.Map<java.lang.String,java.lang.Object>` `headers()`
`DefaultHttpServerResponse` `putHeader(java.lang.String key, java.lang.Object value)` Put an HTTP header - fluent API
`DefaultHttpServerResponse` `putTrailer(java.lang.String key, java.lang.Object value)` Put an HTTP trailer - fluent API
`DefaultHttpServerResponse` `sendFile(java.lang.String filename)` 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.
`DefaultHttpServerResponse` `setChunked(boolean chunked)` 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.
`void` `setWriteQueueMaxSize(int size)` Set the maximum size of the write queue to `maxSize`.
`java.util.Map<java.lang.String,java.lang.Object>` `trailers()`
`DefaultHttpServerResponse` `write(Buffer chunk)` Write a `Buffer` to the response body.
`DefaultHttpServerResponse` `write(Buffer chunk, Handler<java.lang.Void> doneHandler)` Write a `Buffer` to the response body.
`DefaultHttpServerResponse` `write(java.lang.String chunk)` Write a `String` to the response body, encoded in UTF-8.
`DefaultHttpServerResponse` `write(java.lang.String chunk, Handler<java.lang.Void> doneHandler)` Write a `String` to the response body, encoded in UTF-8.
`DefaultHttpServerResponse` `write(java.lang.String chunk, java.lang.String enc)` Write a `String` to the response body, encoded using the encoding `enc`.
`DefaultHttpServerResponse` `write(java.lang.String chunk, java.lang.String enc, Handler<java.lang.Void> doneHandler)` Write a `String` to the response body, encoded with encoding `enc`.
`void` `writeBuffer(Buffer chunk)` Write some data to the stream.
`boolean` `writeQueueFull()` This will return `true` if there are more bytes in the write queue than the value set using `WriteStream.setWriteQueueMaxSize(int)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Method Detail

#### headers

    public java.util.Map<java.lang.String,java.lang.Object> headers()

Specified by:
  `headers` in class `HttpServerResponse`
Returns:
  The HTTP headers

#### trailers

    public java.util.Map<java.lang.String,java.lang.Object> trailers()

Specified by:
  `trailers` in class `HttpServerResponse`
Returns:
  The HTTP trailers

#### setChunked

    public DefaultHttpServerResponse setChunked(boolean chunked)

Description copied from class: `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 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.

Specified by:
  `setChunked` in class `HttpServerResponse`
Returns:
  A reference to this, so multiple method calls can be chained.

#### putHeader

    public DefaultHttpServerResponse putHeader(java.lang.String key,
                                      java.lang.Object value)

Description copied from class: `HttpServerResponse`
Put an HTTP header - fluent API

Specified by:
  `putHeader` in class `HttpServerResponse`
Parameters:
  `key` - The header name
  `value` - The header value
Returns:
  A reference to this, so multiple method calls can be chained.

#### putTrailer

    public DefaultHttpServerResponse putTrailer(java.lang.String key,
                                       java.lang.Object value)

Description copied from class: `HttpServerResponse`
Put an HTTP trailer - fluent API

Specified by:
  `putTrailer` in class `HttpServerResponse`
Parameters:
  `key` - The trailer name
  `value` - The trailer value
Returns:
  A reference to this, so multiple method calls can be chained.

#### setWriteQueueMaxSize

    public void setWriteQueueMaxSize(int size)

Description copied from interface: `WriteStream`
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.

#### writeQueueFull

    public boolean writeQueueFull()

Description copied from interface: `WriteStream`
This will return `true` if there are more bytes in the write queue than the value set using `WriteStream.setWriteQueueMaxSize(int)`

#### drainHandler

    public void drainHandler(Handler<java.lang.Void> handler)

Description copied from interface: `WriteStream`
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 `Pump` for an example of this being used.

#### exceptionHandler

    public void exceptionHandler(Handler<java.lang.Exception> handler)

Description copied from interface: `WriteStream`
Set an exception handler on the stream

#### closeHandler

    public void closeHandler(Handler<java.lang.Void> handler)

Description copied from class: `HttpServerResponse`
Set a close handler for the response. This will be called if the underlying connection closes before the response is complete.

Specified by:
  `closeHandler` in class `HttpServerResponse`

#### writeBuffer

    public void writeBuffer(Buffer chunk)

Description copied from interface: `WriteStream`
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 `WriteStream.writeQueueFull()` method before writing. This is done automatically if using a `Pump`.

#### write

    public DefaultHttpServerResponse write(Buffer chunk)

Description copied from class: `HttpServerResponse`
Write a `Buffer` to the response body.

Specified by:
  `write` in class `HttpServerResponse`
Returns:
  A reference to this, so multiple method calls can be chained.

#### write

    public DefaultHttpServerResponse write(java.lang.String chunk,
                                  java.lang.String enc)

Description copied from class: `HttpServerResponse`
Write a `String` to the response body, encoded using the encoding `enc`.

Specified by:
  `write` in class `HttpServerResponse`
Returns:
  A reference to this, so multiple method calls can be chained.

#### write

    public DefaultHttpServerResponse write(java.lang.String chunk)

Description copied from class: `HttpServerResponse`
Write a `String` to the response body, encoded in UTF-8.

Specified by:
  `write` in class `HttpServerResponse`
Returns:
  A reference to this, so multiple method calls can be chained.

#### write

    public DefaultHttpServerResponse write(Buffer chunk,
                                  Handler<java.lang.Void> doneHandler)

Description copied from class: `HttpServerResponse`
Write a `Buffer` to the response body. The `doneHandler` is called after the buffer is actually written to the wire.

Specified by:
  `write` in class `HttpServerResponse`
Returns:
  A reference to this, so multiple method calls can be chained.

#### write

    public DefaultHttpServerResponse write(java.lang.String chunk,
                                  java.lang.String enc,
                                  Handler<java.lang.Void> doneHandler)

Description copied from class: `HttpServerResponse`
Write a `String` to the response body, encoded with encoding `enc`. The `doneHandler` is called after the buffer is actually written to the wire.

Specified by:
  `write` in class `HttpServerResponse`
Returns:
  A reference to this, so multiple method calls can be chained.

#### write

    public DefaultHttpServerResponse write(java.lang.String chunk,
                                  Handler<java.lang.Void> doneHandler)

Description copied from class: `HttpServerResponse`
Write a `String` to the response body, encoded in UTF-8. The `doneHandler` is called after the buffer is actually written to the wire.

Specified by:
  `write` in class `HttpServerResponse`
Returns:
  A reference to this, so multiple method calls can be chained.

#### end

    public void end(java.lang.String chunk)

Description copied from class: `HttpServerResponse`
Same as `HttpServerResponse.end(Buffer)` but writes a String with the default encoding before ending the response.

Specified by:
  `end` in class `HttpServerResponse`

#### end

    public void end(java.lang.String chunk,
           java.lang.String enc)

Description copied from class: `HttpServerResponse`
Same as `HttpServerResponse.end(Buffer)` but writes a String with the specified encoding before ending the response.

Specified by:
  `end` in class `HttpServerResponse`

#### end

    public void end(Buffer chunk)

Description copied from class: `HttpServerResponse`
Same as `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

Specified by:
  `end` in class `HttpServerResponse`

#### close

    public void close()

Description copied from class: `HttpServerResponse`
Close the underlying TCP connection

Specified by:
  `close` in class `HttpServerResponse`

#### end

    public void end()

Description copied from class: `HttpServerResponse`
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.

Specified by:
  `end` in class `HttpServerResponse`

#### sendFile

    public DefaultHttpServerResponse sendFile(java.lang.String filename)

Description copied from class: `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. This is a very efficient way to serve files.

Specified by:
  `sendFile` in class `HttpServerResponse`