vertx / io.vertx.reactivex.core.http / HttpClientRequest

# HttpClientRequest

`open class HttpClientRequest : WriteStream<Buffer>, ReadStream<HttpClientResponse>`

Represents a client-side HTTP request.

Instances are created by an io.vertx.reactivex.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.reactivex.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.reactivex.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.reactivex.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.reactivex.core.streams.WriteStream so it can be used with io.vertx.reactivex.core.streams.Pump to pump data with flow control.

An example of using this class is as follows:

NOTE: This class has been automatically generated from the io.vertx.core.http.HttpClientRequest non RX-ified interface using Vert.x codegen.

### Constructors

<init> | `HttpClientRequest(delegate: HttpClientRequest)`

### Properties

__TYPE_ARG | `static val __TYPE_ARG: TypeArg<HttpClientRequest>`

### Functions

absoluteURI | `open fun absoluteURI(): String`
connection | `open fun connection(): HttpConnection`
connectionHandler | `open fun connectionHandler(handler: Handler<HttpConnection>): HttpClientRequest` Set a connection handler called when an HTTP connection has been established.
continueHandler | `open fun continueHandler(handler: Handler<Void>): 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. 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.reactivex.core.http.HttpClientRequest#sendHead` method to force the request header to be written before the request has ended.
drainHandler | `open fun drainHandler(handler: Handler<Void>): HttpClientRequest`
end | `open fun end(chunk: String): Unit` Same as `io.vertx.reactivex.core.http.HttpClientRequest#end` but writes a String in UTF-8 encoding `open fun end(chunk: String, enc: String): Unit` Same as `io.vertx.reactivex.core.http.HttpClientRequest#end` but writes a String with the specified encoding `open fun end(chunk: Buffer): Unit` Same as `io.vertx.reactivex.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 `open fun end(): Unit` Ends the request. If no data has been written to the request body, and `io.vertx.reactivex.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,
endHandler | `open fun endHandler(endHandler: Handler<Void>): HttpClientRequest`
equals | `open fun equals(other: Any?): Boolean`
exceptionHandler | `open fun exceptionHandler(handler: Handler<Throwable>): HttpClientRequest`
getDelegate | `open fun getDelegate(): HttpClientRequest`
getHost | `open fun getHost(): String`
getRawMethod | `open fun getRawMethod(): String`
handler | `open fun handler(handler: Handler<HttpClientResponse>): HttpClientRequest`
hashCode | `open fun hashCode(): Int`
headers | `open fun headers(): MultiMap`
isChunked | `open fun isChunked(): Boolean`
method | `open fun method(): HttpMethod` The HTTP method for the request.
newInstance | `open static fun newInstance(arg: HttpClientRequest): HttpClientRequest`
path | `open fun path(): String`
pause | `open fun pause(): HttpClientRequest`
pushHandler | `open fun pushHandler(handler: Handler<HttpClientRequest>): HttpClientRequest` 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.reactivex.core.http.HttpClientRequest, the following methods can be called: `io.vertx.reactivex.core.http.HttpClientRequest#method` `io.vertx.reactivex.core.http.HttpClientRequest#uri` `io.vertx.reactivex.core.http.HttpClientRequest#headers` `io.vertx.reactivex.core.http.HttpClientRequest#getHost` In addition the handler should call the `io.vertx.reactivex.core.http.HttpClientRequest#handler` method to set an handler to process the response.
putHeader | `open fun putHeader(name: String, value: String): HttpClientRequest` Put an HTTP header
query | `open fun query(): String`
reset | `open fun reset(): Boolean` Reset this stream with the error code `0`. `open fun reset(code: Long): Boolean` 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 after the current in-flight requests are ended When the request has not yet been sent, the request will be aborted and false is returned as indicator.
resume | `open fun resume(): HttpClientRequest`
sendHead | `open fun sendHead(): HttpClientRequest` Forces the head of the request to be written before `io.vertx.reactivex.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. `open fun sendHead(completionHandler: Handler<HttpVersion>): HttpClientRequest` Like `io.vertx.reactivex.core.http.HttpClientRequest#sendHead` but with an handler after headers have been sent. The handler will be called with the io.vertx.reactivex.core.http.HttpVersion if it can be determined or null otherwise.
setChunked | `open fun setChunked(chunked: Boolean): HttpClientRequest` If chunked is true then the request will be set into HTTP chunked mode
setFollowRedirects | `open fun setFollowRedirects(followRedirects: Boolean): HttpClientRequest`
setHost | `open fun setHost(host: String): HttpClientRequest` Set the request host. For HTTP/2 it sets the pseudo header otherwise it sets the header
setRawMethod | `open fun setRawMethod(method: String): HttpClientRequest` Set the value the method to send when the method is used.
setTimeout | `open fun 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 java.util.concurrent.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.
setWriteQueueMaxSize | `open fun setWriteQueueMaxSize(maxSize: Int): HttpClientRequest`
streamId | `open fun streamId(): Int`
toFlowable | `open fun toFlowable(): Flowable<HttpClientResponse>`
toObservable | `open fun toObservable(): Observable<HttpClientResponse>`
toString | `open fun toString(): String`
uri | `open fun uri(): String`
write | `open fun write(data: Buffer): HttpClientRequest` `open fun write(chunk: String): HttpClientRequest` Write a java.lang.String to the request body, encoded as UTF-8. `open fun write(chunk: String, enc: String): HttpClientRequest` Write a java.lang.String to the request body, encoded using the encoding `enc`.
writeCustomFrame | `open fun writeCustomFrame(type: Int, flags: Int, payload: Buffer): HttpClientRequest` 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.reactivex.core.http.HttpClientRequest#sendHead` should be used for this purpose. `open fun writeCustomFrame(frame: HttpFrame): HttpClientRequest` Like `io.vertx.reactivex.core.http.HttpClientRequest#writeCustomFrame` but with an io.vertx.reactivex.core.http.HttpFrame.
writeQueueFull | `open fun writeQueueFull(): Boolean` This will return `true` if there are more bytes in the write queue than the value set using `io.vertx.reactivex.core.http.HttpClientRequest#setWriteQueueMaxSize`