vertx / io.vertx.core.http / HttpClientResponse

HttpClientResponse

interface HttpClientResponse : ReadStream<Buffer>

Represents a client-side HTTP response.

Vert.x provides you with one of these via the handler that was provided when creating the io.vertx.core.http.HttpClientRequest or that was set on the io.vertx.core.http.HttpClientRequest instance.

It implements io.vertx.core.streams.ReadStream so it can be used with io.vertx.core.streams.Pump to pump data with flow control.

Author
Tim Fox

Functions

bodyHandler

abstract fun bodyHandler(bodyHandler: Handler<Buffer>): HttpClientResponse

Convenience method for receiving the entire request body in one piece.

This saves you having to manually set a dataHandler and an endHandler and append the chunks of the body until the whole body received. Don't use this if your request body is large - you could potentially run out of RAM.

cookies

abstract fun cookies(): MutableList<String>

customFrameHandler

abstract fun customFrameHandler(handler: Handler<HttpFrame>): HttpClientResponse

Set an custom frame handler. The handler will get notified when the http stream receives an custom HTTP/2 frame. HTTP/2 permits extension of the protocol.

endHandler

abstract fun endHandler(endHandler: Handler<Void>): HttpClientResponse

exceptionHandler

abstract fun exceptionHandler(handler: Handler<Throwable>): HttpClientResponse

getHeader

abstract fun getHeader(headerName: String): String
abstract fun getHeader(headerName: CharSequence): String

Return the first header value with the specified name

getTrailer

abstract fun getTrailer(trailerName: String): String

Return the first trailer value with the specified name

handler

abstract fun handler(handler: Handler<Buffer>): HttpClientResponse

headers

abstract fun headers(): MultiMap

netSocket

abstract fun netSocket(): NetSocket

Get a net socket for the underlying connection of this request.

USE THIS WITH CAUTION! Writing to the socket directly if you don't know what you're doing can easily break the HTTP protocol

One valid use-case for calling this is to receive the io.vertx.core.net.NetSocket after a HTTP CONNECT was issued to the remote peer and it responded with a status code of 200.

pause

abstract fun pause(): HttpClientResponse

request

abstract fun request(): HttpClientRequest

resume

abstract fun resume(): HttpClientResponse

statusCode

abstract fun statusCode(): Int

statusMessage

abstract fun statusMessage(): String

trailers

abstract fun trailers(): MultiMap

version

abstract fun version(): HttpVersion