io.vertx.rxjava.core.http

## Class HttpServerRequest

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

- All Implemented Interfaces:
    ReadStream<Buffer>, StreamBase

      public class HttpServerRequest
      extends Object
      implements ReadStream<Buffer>

  Represents a server-side HTTP request.

  Instances are created for each request and passed to the user via a handler.

  Each instance of this class is associated with a corresponding `HttpServerResponse` instance via `response()`.

  It implements `ReadStream` so it can be used with `Pipe` to pipe data with flow control.

  NOTE: This class has been automatically generated from the `original` non RX-ified interface using Vert.x codegen.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static io.vertx.lang.rx.TypeArg<HttpServerRequest>` | `__TYPE_ARG`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `HttpServerRequest(HttpServerRequest delegate)`
    `HttpServerRequest(Object delegate)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `absoluteURI()`
    `HttpServerRequest` | `body(Handler<AsyncResult<Buffer>> handler)` Same as `body(io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.core.buffer.Buffer>>)` but with an `handler` called when the operation completes
    `HttpServerRequest` | `bodyHandler(Handler<Buffer> bodyHandler)` Convenience method for receiving the entire request body in one piece.
    `long` | `bytesRead()`
    `HttpConnection` | `connection()`
    `int` | `cookieCount()`
    `Map<String,Cookie>` | `cookieMap()` Deprecated.
    `Set<Cookie>` | `cookies()` Returns a modifiable set of parsed cookies from the `COOKIE` header.
    `Set<Cookie>` | `cookies(String name)` Returns a read only set of parsed cookies that match the given name, or an empty set.
    `HttpServerRequest` | `customFrameHandler(Handler<HttpFrame> handler)` Set a custom frame handler.
    `void` | `end()` Same as `end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)` but with an `handler` called when the operation completes
    `void` | `end(Handler<AsyncResult<Void>> handler)` Same as `end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)` but with an `handler` called when the operation completes
    `HttpServerRequest` | `endHandler(Handler<Void> endHandler)` Set an end handler.
    `boolean` | `equals(Object o)`
    `HttpServerRequest` | `exceptionHandler(Handler<Throwable> handler)` Set an exception handler on the read stream.
    `HttpServerRequest` | `fetch(long amount)` Fetch the specified `amount` of elements.
    `MultiMap` | `formAttributes()` Returns a map of all form attributes in the request.
    `Cookie` | `getCookie(String name)` Get the cookie with the specified name.
    `Cookie` | `getCookie(String name, String domain, String path)` Get the cookie with the specified ``.
    `HttpServerRequest` | `getDelegate()`
    `String` | `getFormAttribute(String attributeName)` Return the first form attribute value with the specified name
    `String` | `getHeader(CharSequence headerName)` Return the first header value with the specified name
    `String` | `getHeader(String headerName)` Return the first header value with the specified name
    `String` | `getParam(String paramName)` Return the first param value with the specified name
    `String` | `getParam(String paramName, String defaultValue)` Return the first param value with the specified name or `defaultValue` when the query param is not present
    `HttpServerRequest` | `handler(Handler<Buffer> handler)` Set a data handler.
    `int` | `hashCode()`
    `MultiMap` | `headers()`
    `String` | `host()`
    `boolean` | `isEnded()` Has the request ended? I.e.
    `boolean` | `isExpectMultipart()`
    `boolean` | `isSSL()`
    `SocketAddress` | `localAddress()`
    `HttpMethod` | `method()`
    `static HttpServerRequest` | `newInstance(HttpServerRequest arg)`
    `MultiMap` | `params()`
    `String` | `path()`
    `HttpServerRequest` | `pause()` Pause the `ReadStream`, it sets the buffer in `fetch` mode and clears the actual demand.
    `Pipe<Buffer>` | `pipe()` Pause this stream and return a to transfer the elements of this stream to a destination .
    `void` | `pipeTo(WriteStream<Buffer> dst)` Pipe this `ReadStream` to the `WriteStream`.
    `void` | `pipeTo(WriteStream<Buffer> dst, Handler<AsyncResult<Void>> handler)` Pipe this `ReadStream` to the `WriteStream`.
    `String` | `query()`
    `SocketAddress` | `remoteAddress()`
    `HttpServerResponse` | `response()`
    `HttpServerRequest` | `resume()` Resume reading, and sets the buffer in `flowing` mode.
    `HttpServerRequest` | `routed(String route)` Marks this request as being routed to the given route.
    `Single<Void>` | `rxEnd()` Same as `end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)` but with an `handler` called when the operation completes
    `Single<Void>` | `rxPipeTo(WriteStream<Buffer> dst)` Pipe this `ReadStream` to the `WriteStream`.
    `Single<NetSocket>` | `rxToNetSocket()` Establish a TCP tunnel with the client.
    `Single<ServerWebSocket>` | `rxToWebSocket()` Upgrade the connection of the current request to a WebSocket.
    `String` | `scheme()`
    `HttpServerRequest` | `setExpectMultipart(boolean expect)` Call this with true if you are expecting a multi-part body to be submitted in the request.
    `SSLSession` | `sslSession()`
    `int` | `streamId()`
    `StreamPriority` | `streamPriority()`
    `HttpServerRequest` | `streamPriorityHandler(Handler<StreamPriority> handler)` Set an handler for stream priority changes
    `void` | `toNetSocket()` Establish a TCP tunnel with the client.
    `void` | `toNetSocket(Handler<AsyncResult<NetSocket>> handler)` Establish a TCP tunnel with the client.
    `Observable<Buffer>` | `toObservable()`
    `String` | `toString()`
    `void` | `toWebSocket()` Upgrade the connection of the current request to a WebSocket.
    `void` | `toWebSocket(Handler<AsyncResult<ServerWebSocket>> handler)` Upgrade the connection of the current request to a WebSocket.
    `HttpServerRequest` | `uploadHandler(Handler<HttpServerFileUpload> uploadHandler)` Set an upload handler.
    `String` | `uri()`
    `HttpVersion` | `version()`

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

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

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

      `newInstance, newInstance`

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

      `newInstance`

- - ### Field Detail

    - #### __TYPE_ARG

          public static final io.vertx.lang.rx.TypeArg<HttpServerRequest> __TYPE_ARG

  - ### Constructor Detail

    - #### HttpServerRequest

          public HttpServerRequest(HttpServerRequest delegate)

    - #### HttpServerRequest

          public HttpServerRequest(Object delegate)

  - ### Method Detail

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### equals

          public boolean equals(Object o)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### getDelegate

          public HttpServerRequest getDelegate()

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

    - #### toObservable

          public Observable<Buffer> toObservable()

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

    - #### pipe

          public Pipe<Buffer> pipe()

      Pause this stream and return a to transfer the elements of this stream to a destination .

      The stream will be resumed when the pipe will be wired to a `WriteStream`.
      Specified by:
        `pipe` in interface `ReadStream<Buffer>`
      Returns:
        a pipe

    - #### pipeTo

          public void pipeTo(WriteStream<Buffer> dst,
                             Handler<AsyncResult<Void>> handler)

      Pipe this `ReadStream` to the `WriteStream`.

      Elements emitted by this stream will be written to the write stream until this stream ends or fails.

      Once this stream has ended or failed, the write stream will be ended and the `handler` will be called with the result.

      Specified by:
        `pipeTo` in interface `ReadStream<Buffer>`
      Parameters:
        `dst` - the destination write stream
        `handler` -

    - #### pipeTo

          public void pipeTo(WriteStream<Buffer> dst)

      Pipe this `ReadStream` to the `WriteStream`.

      Elements emitted by this stream will be written to the write stream until this stream ends or fails.

      Once this stream has ended or failed, the write stream will be ended and the `handler` will be called with the result.

      Specified by:
        `pipeTo` in interface `ReadStream<Buffer>`
      Parameters:
        `dst` - the destination write stream

    - #### rxPipeTo

          public Single<Void> rxPipeTo(WriteStream<Buffer> dst)

      Pipe this `ReadStream` to the `WriteStream`.

      Elements emitted by this stream will be written to the write stream until this stream ends or fails.

      Once this stream has ended or failed, the write stream will be ended and the `handler` will be called with the result.

      Specified by:
        `rxPipeTo` in interface `ReadStream<Buffer>`
      Parameters:
        `dst` - the destination write stream
      Returns:

    - #### exceptionHandler

          public HttpServerRequest exceptionHandler(Handler<Throwable> handler)

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

    - #### handler

          public HttpServerRequest handler(Handler<Buffer> 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<Buffer>`
      Returns:
        a reference to this, so the API can be used fluently

    - #### pause

          public HttpServerRequest pause()

      Description copied from interface: `ReadStream`
      Pause the `ReadStream`, it sets the buffer in `fetch` mode and clears the actual demand.

      While it's paused, no data will be sent to the data `handler`.

      Specified by:
        `pause` in interface `ReadStream<Buffer>`
      Returns:
        a reference to this, so the API can be used fluently

    - #### resume

          public HttpServerRequest resume()

      Description copied from interface: `ReadStream`
      Resume reading, and sets the buffer in `flowing` mode.

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

    - #### fetch

          public HttpServerRequest fetch(long amount)

      Description copied from interface: `ReadStream`
      Fetch the specified `amount` of elements. If the `ReadStream` has been paused, reading will recommence with the specified `amount` of items, otherwise the specified `amount` will be added to the current stream demand.
      Specified by:
        `fetch` in interface `ReadStream<Buffer>`
      Returns:
        a reference to this, so the API can be used fluently

    - #### endHandler

          public HttpServerRequest 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<Buffer>`
      Returns:
        a reference to this, so the API can be used fluently

    - #### version

          public HttpVersion version()

      Returns:
        the HTTP version of the request

    - #### method

          public HttpMethod method()

      Returns:
        the HTTP method for the request.

    - #### isSSL

          public boolean isSSL()

      Returns:
        true if this `NetSocket` is encrypted via SSL/TLS

    - #### scheme

          public String scheme()

      Returns:
        the scheme of the request

    - #### uri

          public String uri()

      Returns:
        the URI of the request. This is usually a relative URI

    - #### path

          public String path()

      Returns:
        The path part of the uri. For example /somepath/somemorepath/someresource.foo

    - #### query

          public String query()

      Returns:
        the query part of the uri. For example someparam=32&someotherparam=x

    - #### host

          public String host()

      Returns:
        the request host. For HTTP2 it returns the pseudo header otherwise it returns the header

    - #### bytesRead

          public long bytesRead()

      Returns:
        the total number of bytes read for the body of the request.

    - #### response

          public HttpServerResponse response()

      Returns:
        the response. Each instance of this class has an `HttpServerResponse` instance attached to it. This is used to send the response back to the client.

    - #### headers

          public MultiMap headers()

      Returns:
        the headers in the request.

    - #### getHeader

          public String getHeader(String headerName)

      Return the first header value with the specified name
      Parameters:
        `headerName` - the header name
      Returns:
        the header value

    - #### params

          public MultiMap params()

      Returns:
        the query parameters in the request

    - #### getParam

          public String getParam(String paramName)

      Return the first param value with the specified name
      Parameters:
        `paramName` - the param name
      Returns:
        the param value

    - #### getParam

          public String getParam(String paramName,
                                 String defaultValue)

      Return the first param value with the specified name or `defaultValue` when the query param is not present
      Parameters:
        `paramName` - the param name
        `defaultValue` - the default value, must be non-null
      Returns:
        the param value or `defaultValue` when not present

    - #### remoteAddress

          public SocketAddress remoteAddress()

      Returns:
        the remote address for this connection, possibly `null` (e.g a server bound on a domain socket). If `useProxyProtocol` is set to `true`, the address returned will be of the actual connecting client.

    - #### localAddress

          public SocketAddress localAddress()

      Returns:
        the local address for this connection, possibly `null` (e.g a server bound on a domain socket) If `useProxyProtocol` is set to `true`, the address returned will be of the proxy.

    - #### absoluteURI

          public String absoluteURI()

      Returns:
        the absolute URI corresponding to the HTTP request

    - #### bodyHandler

          public HttpServerRequest bodyHandler(Handler<Buffer> bodyHandler)

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

      This saves the user having to manually setting a data and end handler 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.

      Parameters:
        `bodyHandler` - This handler will be called after all the body has been received
      Returns:

    - #### body

          public HttpServerRequest body(Handler<AsyncResult<Buffer>> handler)

      Same as `body(io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.core.buffer.Buffer>>)` but with an `handler` called when the operation completes
      Parameters:
        `handler` -
      Returns:

    - #### end

          public void end(Handler<AsyncResult<Void>> handler)

      Same as `end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)` but with an `handler` called when the operation completes
      Parameters:
        `handler` -

    - #### end

          public void end()

      Same as `end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)` but with an `handler` called when the operation completes

    - #### rxEnd

          public Single<Void> rxEnd()

      Same as `end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)` but with an `handler` called when the operation completes
      Returns:

    - #### toNetSocket

          public void toNetSocket(Handler<AsyncResult<NetSocket>> handler)

      Establish a TCP tunnel with the client.

      This must be called only for `CONNECT` HTTP method and before any response is sent.

      Calling this sends a `200` response with no `content-length` header set and then provides the `NetSocket` for handling the created tunnel. Any HTTP header set on the response before calling this method will be sent.

           server.requestHandler(req -> {
             if (req.method() == HttpMethod.CONNECT) {
               // Send a 200 response to accept the connect
               NetSocket socket = req.netSocket();
               socket.handler(buff -> {
                 socket.write(buff);
               });
             }
             ...
           });

      Parameters:
        `handler` - the completion handler

    - #### toNetSocket

          public void toNetSocket()

      Establish a TCP tunnel with the client.

      This must be called only for `CONNECT` HTTP method and before any response is sent.

      Calling this sends a `200` response with no `content-length` header set and then provides the `NetSocket` for handling the created tunnel. Any HTTP header set on the response before calling this method will be sent.

           server.requestHandler(req -> {
             if (req.method() == HttpMethod.CONNECT) {
               // Send a 200 response to accept the connect
               NetSocket socket = req.netSocket();
               socket.handler(buff -> {
                 socket.write(buff);
               });
             }
             ...
           });

    - #### rxToNetSocket

          public Single<NetSocket> rxToNetSocket()

      Establish a TCP tunnel with the client.

      This must be called only for `CONNECT` HTTP method and before any response is sent.

      Calling this sends a `200` response with no `content-length` header set and then provides the `NetSocket` for handling the created tunnel. Any HTTP header set on the response before calling this method will be sent.

           server.requestHandler(req -> {
             if (req.method() == HttpMethod.CONNECT) {
               // Send a 200 response to accept the connect
               NetSocket socket = req.netSocket();
               socket.handler(buff -> {
                 socket.write(buff);
               });
             }
             ...
           });

      Returns:

    - #### setExpectMultipart

          public HttpServerRequest setExpectMultipart(boolean expect)

      Call this with true if you are expecting a multi-part body to be submitted in the request. This must be called before the body of the request has been received
      Parameters:
        `expect` - true - if you are expecting a multi-part body
      Returns:
        a reference to this, so the API can be used fluently

    - #### isExpectMultipart

          public boolean isExpectMultipart()

      Returns:
        true if we are expecting a multi-part body for this request. See `setExpectMultipart(boolean)`.

    - #### uploadHandler

          public HttpServerRequest uploadHandler(Handler<HttpServerFileUpload> uploadHandler)

      Set an upload handler. The handler will get notified once a new file upload was received to allow you to deal with the file upload.
      Parameters:
        `uploadHandler` -
      Returns:
        a reference to this, so the API can be used fluently

    - #### formAttributes

          public MultiMap formAttributes()

      Returns a map of all form attributes in the request.

      Be aware that the attributes will only be available after the whole body has been received, i.e. after the request end handler has been called.

      `setExpectMultipart(boolean)` must be called first before trying to get the form attributes.

      Returns:
        the form attributes

    - #### getFormAttribute

          public String getFormAttribute(String attributeName)

      Return the first form attribute value with the specified name
      Parameters:
        `attributeName` - the attribute name
      Returns:
        the attribute value

    - #### streamId

          public int streamId()

      Returns:
        the id of the stream of this request, when it is not yet determined, i.e the request has not been yet sent or it is not supported HTTP/1.x

    - #### toWebSocket

          public void toWebSocket(Handler<AsyncResult<ServerWebSocket>> handler)

      Upgrade the connection of the current request to a WebSocket.

      This is an alternative way of handling WebSockets and can only be used if no WebSocket handler is set on the `HttpServer`, and can only be used during the upgrade request during the WebSocket handshake.

      Both `handler(io.vertx.core.Handler<io.vertx.rxjava.core.buffer.Buffer>)` and `endHandler(io.vertx.core.Handler<java.lang.Void>)` will be set to get the full body of the request that is necessary to perform the WebSocket handshake.

      If you need to do an asynchronous upgrade, i.e not performed immediately in your request handler, you need to `pause()` the request in order to not lose HTTP events necessary to upgrade the request.

      Parameters:
        `handler` - the completion handler

    - #### toWebSocket

          public void toWebSocket()

      Upgrade the connection of the current request to a WebSocket.

      This is an alternative way of handling WebSockets and can only be used if no WebSocket handler is set on the `HttpServer`, and can only be used during the upgrade request during the WebSocket handshake.

      Both `handler(io.vertx.core.Handler<io.vertx.rxjava.core.buffer.Buffer>)` and `endHandler(io.vertx.core.Handler<java.lang.Void>)` will be set to get the full body of the request that is necessary to perform the WebSocket handshake.

      If you need to do an asynchronous upgrade, i.e not performed immediately in your request handler, you need to `pause()` the request in order to not lose HTTP events necessary to upgrade the request.

    - #### rxToWebSocket

          public Single<ServerWebSocket> rxToWebSocket()

      Upgrade the connection of the current request to a WebSocket.

      This is an alternative way of handling WebSockets and can only be used if no WebSocket handler is set on the `HttpServer`, and can only be used during the upgrade request during the WebSocket handshake.

      Both `handler(io.vertx.core.Handler<io.vertx.rxjava.core.buffer.Buffer>)` and `endHandler(io.vertx.core.Handler<java.lang.Void>)` will be set to get the full body of the request that is necessary to perform the WebSocket handshake.

      If you need to do an asynchronous upgrade, i.e not performed immediately in your request handler, you need to `pause()` the request in order to not lose HTTP events necessary to upgrade the request.

      Returns:

    - #### isEnded

          public boolean isEnded()

      Has the request ended? I.e. has the entire request, including the body been read?
      Returns:
        true if ended

    - #### customFrameHandler

          public HttpServerRequest customFrameHandler(Handler<HttpFrame> handler)

      Set a 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.
      Parameters:
        `handler` -
      Returns:
        a reference to this, so the API can be used fluently

    - #### connection

          public HttpConnection connection()

      Returns:
        the `HttpConnection` associated with this request

    - #### streamPriority

          public StreamPriority streamPriority()

      Returns:
        the priority of the associated HTTP/2 stream for HTTP/2 otherwise `null`

    - #### streamPriorityHandler

          public HttpServerRequest streamPriorityHandler(Handler<StreamPriority> handler)

      Set an handler for stream priority changes

      This is not implemented for HTTP/1.x.

      Parameters:
        `handler` - the handler to be called when stream priority changes
      Returns:

    - #### getCookie

          public Cookie getCookie(String name)

      Get the cookie with the specified name. NOTE: this will return just the 1st `Cookie` that matches the given name, to get all cookies for this name see: `cookies(java.lang.String)`
      Parameters:
        `name` - the cookie name
      Returns:
        the cookie or `null` if not found.

    - #### getCookie

          public Cookie getCookie(String name,
                                  String domain,
                                  String path)

      Get the cookie with the specified ``.
      Parameters:
        `name` - the cookie name
        `domain` - the cookie domain
        `path` - the cookie path
      Returns:
        the cookie or `null` if not found.

    - #### cookieCount

          public int cookieCount()

      Returns:
        the number of cookies in the cookie jar.

    - #### cookieMap

          @Deprecated
          public Map<String,Cookie> cookieMap()

      Deprecated.
      Returns:
        a map of all the cookies.

    - #### cookies

          public Set<Cookie> cookies(String name)

      Returns a read only set of parsed cookies that match the given name, or an empty set. Several cookies may share the same name but have different keys. A cookie is unique by its `` tuple. The set entries are references to the request original set. This means that performing property changes in the cookie objects will affect the original object too. NOTE: the returned is read-only. This means any attempt to modify (add or remove to the set), will throw `UnsupportedOperationException`.
      Parameters:
        `name` - the name to be matches
      Returns:
        the matching cookies or empty set

    - #### cookies

          public Set<Cookie> cookies()

      Returns a modifiable set of parsed cookies from the `COOKIE` header. Several cookies may share the same name but have different keys. A cookie is unique by its `` tuple. Request cookies are directly linked to response cookies. Any modification to a cookie object in the returned set will mark the cookie to be included in the HTTP response. Removing a cookie from the set, will also mean that it will be removed from the response, regardless if it was modified or not.
      Returns:
        a set with all cookies in the cookie jar.

    - #### routed

          public HttpServerRequest routed(String route)

      Marks this request as being routed to the given route. This is purely informational and is being provided to metrics.
      Parameters:
        `route` - The route this request has been routed to.
      Returns:

    - #### getHeader

          public String getHeader(CharSequence headerName)

      Return the first header value with the specified name
      Parameters:
        `headerName` - the header name
      Returns:
        the header value

    - #### sslSession

          public SSLSession sslSession()

      Returns:
        SSLSession associated with the underlying socket. Returns null if connection is not SSL.

    - #### newInstance

          public static HttpServerRequest newInstance(HttpServerRequest arg)

Copyright © 2021 Eclipse. All rights reserved.