io.vertx.rxjava.core.http

## Class HttpClientRequest

- java.lang.Object
- - io.vertx.rxjava.core.http.HttpClientRequest

- All Implemented Interfaces:
    ReadStream<HttpClientResponse>, StreamBase, WriteStream<Buffer>

      public class HttpClientRequest
      extends Object
      implements WriteStream<Buffer>, ReadStream<HttpClientResponse>

  Represents a client-side HTTP request.

  Instances are created by an `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 `end(java.lang.String)` methods should be called.

  Nothing is actually sent until the request has been internally assigned an HTTP connection.

  The `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 `end(java.lang.String)` 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 `WriteStream` so it can be used with `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 `original` non RX-ified interface using Vert.x codegen.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `HttpClientRequest(HttpClientRequest delegate)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `HttpClientRequest` | `continueHandler(Handler<Void> handler)` 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.
    `HttpClientRequest` | `drainHandler(Handler<Void> handler)` Set a drain handler on the stream.
    `void` | `end()` Ends the request.
    `void` | `end(Buffer chunk)` Same as `HttpClientRequest` but writes some data to the request body before ending.
    `void` | `end(String chunk)` Same as `end(java.lang.String)` but writes a String in UTF-8 encoding
    `void` | `end(String chunk, String enc)` Same as `HttpClientRequest` but writes a String with the specified encoding
    `HttpClientRequest` | `endHandler(Handler<Void> endHandler)` Set an end handler.
    `HttpClientRequest` | `exceptionHandler(Handler<Throwable> handler)` Set an exception handler on the write stream.
    `Object` | `getDelegate()`
    `HttpClientRequest` | `handler(Handler<HttpClientResponse> handler)` Set a data handler.
    `MultiMap` | `headers()`
    `boolean` | `isChunked()`
    `HttpMethod` | `method()` The HTTP method for the request.
    `static HttpClientRequest` | `newInstance(HttpClientRequest arg)`
    `HttpClientRequest` | `pause()` Pause the `ReadSupport`.
    `HttpClientRequest` | `putHeader(String name, String value)` Put an HTTP header
    `HttpClientRequest` | `resume()` Resume reading.
    `HttpClientRequest` | `sendHead()` Forces the head of the request to be written before `end(java.lang.String)` is called on the request or any data is written to it.
    `HttpClientRequest` | `setChunked(boolean chunked)` If chunked is true then the request will be set into HTTP chunked mode
    `HttpClientRequest` | `setTimeout(long timeoutMs)` Set's the amount of time after which if a response is not received `TimeoutException` will be sent to the exception handler of this request.
    `HttpClientRequest` | `setWriteQueueMaxSize(int maxSize)` Set the maximum size of the write queue to `maxSize`.
    `rx.Observable<HttpClientResponse>` | `toObservable()`
    `String` | `uri()`
    `HttpClientRequest` | `write(Buffer data)` Write some data to the stream.
    `HttpClientRequest` | `write(String chunk)` Write a `String` to the request body, encoded as UTF-8.
    `HttpClientRequest` | `write(String chunk, String enc)` Write a `String` to the request body, encoded using the encoding `enc`.
    `boolean` | `writeQueueFull()` This will return `true` if there are more bytes in the write queue than the value set using `setWriteQueueMaxSize(int)`

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

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

    - ### Methods inherited from interface io.vertx.rxjava.core.streams.WriteStream

      `newInstance`

    - ### Methods inherited from interface io.vertx.rxjava.core.streams.ReadStream

      `newInstance`

    - ### Methods inherited from interface io.vertx.rxjava.core.streams.StreamBase

      `newInstance`

- - ### Constructor Detail

    - #### HttpClientRequest

          public HttpClientRequest(HttpClientRequest delegate)

  - ### Method Detail

    - #### getDelegate

          public Object getDelegate()

      Specified by:
        `getDelegate` in interface `ReadStream<HttpClientResponse>`
      Specified by:
        `getDelegate` in interface `StreamBase`
      Specified by:
        `getDelegate` in interface `WriteStream<Buffer>`

    - #### toObservable

          public rx.Observable<HttpClientResponse> toObservable()

      Specified by:
        `toObservable` in interface `ReadStream<HttpClientResponse>`

    - #### writeQueueFull

          public boolean writeQueueFull()

      This will return `true` if there are more bytes in the write queue than the value set using `setWriteQueueMaxSize(int)`
      Specified by:
        `writeQueueFull` in interface `WriteStream<Buffer>`
      Returns:
        true if write queue is full

    - #### exceptionHandler

          public HttpClientRequest exceptionHandler(Handler<Throwable> handler)

      Description copied from interface: `WriteStream`
      Set an exception handler on the write stream.
      Specified by:
        `exceptionHandler` in interface `ReadStream<HttpClientResponse>`
      Specified by:
        `exceptionHandler` in interface `StreamBase`
      Specified by:
        `exceptionHandler` in interface `WriteStream<Buffer>`
      Parameters:
        `handler` - the exception handler
      Returns:
        a reference to this, so the API can be used fluently

    - #### write

          public HttpClientRequest write(Buffer data)

      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`.
      Specified by:
        `write` in interface `WriteStream<Buffer>`
      Parameters:
        `data` -
      Returns:
      Throws:
        `IllegalStateException` - when no response handler is set

    - #### setWriteQueueMaxSize

          public HttpClientRequest setWriteQueueMaxSize(int maxSize)

      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.
      Specified by:
        `setWriteQueueMaxSize` in interface `WriteStream<Buffer>`
      Parameters:
        `maxSize` - the max size of the write stream
      Returns:
        a reference to this, so the API can be used fluently

    - #### drainHandler

          public HttpClientRequest drainHandler(Handler<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.
      Specified by:
        `drainHandler` in interface `WriteStream<Buffer>`
      Parameters:
        `handler` - the handler
      Returns:
        a reference to this, so the API can be used fluently

    - #### handler

          public HttpClientRequest handler(Handler<HttpClientResponse> handler)

      Description copied from interface: `ReadStream`
      Set a data handler. As data is read, the handler will be called with the data.
      Specified by:
        `handler` in interface `ReadStream<HttpClientResponse>`
      Returns:
        a reference to this, so the API can be used fluently

    - #### pause

          public HttpClientRequest pause()

      Description copied from interface: `ReadStream`
      Pause the `ReadSupport`. While it's paused, no data will be sent to the `dataHandler`
      Specified by:
        `pause` in interface `ReadStream<HttpClientResponse>`
      Returns:
        a reference to this, so the API can be used fluently

    - #### resume

          public HttpClientRequest resume()

      Description copied from interface: `ReadStream`
      Resume reading. If the `ReadSupport` has been paused, reading will recommence on it.
      Specified by:
        `resume` in interface `ReadStream<HttpClientResponse>`
      Returns:
        a reference to this, so the API can be used fluently

    - #### endHandler

          public HttpClientRequest endHandler(Handler<Void> endHandler)

      Description copied from interface: `ReadStream`
      Set an end handler. Once the stream has ended, and there is no more data to be read, this handler will be called.
      Specified by:
        `endHandler` in interface `ReadStream<HttpClientResponse>`
      Returns:
        a reference to this, so the API can be used fluently

    - #### setChunked

          public HttpClientRequest setChunked(boolean chunked)

      If chunked is true then the request will be set into HTTP chunked mode
      Parameters:
        `chunked` - true if chunked encoding
      Returns:
        a reference to this, so the API can be used fluently

    - #### isChunked

          public boolean isChunked()

      Returns:
        Is the request chunked?

    - #### method

          public HttpMethod method()

      The HTTP method for the request.
      Returns:

    - #### uri

          public String uri()

      Returns:
        The URI of the request.

    - #### headers

          public MultiMap headers()

      Returns:
        The HTTP headers

    - #### putHeader

          public HttpClientRequest putHeader(String name,
                                             String value)

      Put an HTTP header
      Parameters:
        `name` - The header name
        `value` - The header value
      Returns:
        a reference to this, so the API can be used fluently

    - #### write

          public HttpClientRequest write(String chunk)

      Write a `String` to the request body, encoded as UTF-8.
      Parameters:
        `chunk` -
      Returns:
        @return a reference to this, so the API can be used fluently

    - #### write

          public HttpClientRequest write(String chunk,
                                         String enc)

      Write a `String` to the request body, encoded using the encoding `enc`.
      Parameters:
        `chunk` -
        `enc` -
      Returns:
        @return a reference to this, so the API can be used fluently

    - #### continueHandler

          public HttpClientRequest continueHandler(Handler<Void> handler)

      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 `sendHead()` method to force the request header to be written before the request has ended.

      Parameters:
        `handler` -
      Returns:
        a reference to this, so the API can be used fluently

    - #### sendHead

          public HttpClientRequest sendHead()

      Forces the head of the request to be written before `end(java.lang.String)` is called on the request or any data is written to it.

      This is normally used to implement HTTP 100-continue handling, see `continueHandler(io.vertx.core.Handler<java.lang.Void>)` for more information.

      Returns:
        a reference to this, so the API can be used fluently

    - #### end

          public void end(String chunk)

      Same as `end(java.lang.String)` but writes a String in UTF-8 encoding
      Parameters:
        `chunk` -

    - #### end

          public void end(String chunk,
                          String enc)

      Same as `HttpClientRequest` but writes a String with the specified encoding
      Parameters:
        `chunk` -
        `enc` -

    - #### end

          public void end(Buffer chunk)

      Same as `HttpClientRequest` 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
      Parameters:
        `chunk` -

    - #### end

          public void end()

      Ends the request. If no data has been written to the request body, and `HttpClientRequest` 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,

    - #### setTimeout

          public HttpClientRequest setTimeout(long timeoutMs)

      Set's 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.

      Parameters:
        `timeoutMs` - The quantity of time in milliseconds.
      Returns:
        a reference to this, so the API can be used fluently

    - #### newInstance

          public static HttpClientRequest newInstance(HttpClientRequest arg)

Copyright © 2015. All Rights Reserved.