public class HttpServerRequest extends Object implements ReadStream<Buffer>
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.Modifier and Type | Field and Description |
---|---|
static io.vertx.lang.rx.TypeArg<HttpServerRequest> |
__TYPE_ARG |
Constructor and Description |
---|
HttpServerRequest(HttpServerRequest delegate) |
HttpServerRequest(Object delegate) |
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() |
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.
|
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
|
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() |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
newInstance, newInstance
newInstance
public static final io.vertx.lang.rx.TypeArg<HttpServerRequest> __TYPE_ARG
public HttpServerRequest(HttpServerRequest delegate)
public HttpServerRequest(Object delegate)
public HttpServerRequest getDelegate()
getDelegate
in interface ReadStream<Buffer>
getDelegate
in interface StreamBase
public Observable<Buffer> toObservable()
toObservable
in interface ReadStream<Buffer>
public Pipe<Buffer> pipe()
WriteStream
.pipe
in interface ReadStream<Buffer>
public void pipeTo(WriteStream<Buffer> dst, Handler<AsyncResult<Void>> handler)
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.
pipeTo
in interface ReadStream<Buffer>
dst
- the destination write streamhandler
- public void pipeTo(WriteStream<Buffer> dst)
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.
pipeTo
in interface ReadStream<Buffer>
dst
- the destination write streampublic Single<Void> rxPipeTo(WriteStream<Buffer> dst)
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.
rxPipeTo
in interface ReadStream<Buffer>
dst
- the destination write streampublic HttpServerRequest exceptionHandler(Handler<Throwable> handler)
ReadStream
exceptionHandler
in interface ReadStream<Buffer>
exceptionHandler
in interface StreamBase
handler
- the exception handlerpublic HttpServerRequest handler(Handler<Buffer> handler)
ReadStream
handler
in interface ReadStream<Buffer>
public HttpServerRequest pause()
ReadStream
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
.
pause
in interface ReadStream<Buffer>
public HttpServerRequest resume()
ReadStream
flowing
mode.
If the ReadStream
has been paused, reading will recommence on it.resume
in interface ReadStream<Buffer>
public HttpServerRequest fetch(long amount)
ReadStream
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.fetch
in interface ReadStream<Buffer>
public HttpServerRequest endHandler(Handler<Void> endHandler)
ReadStream
endHandler
in interface ReadStream<Buffer>
public HttpVersion version()
public HttpMethod method()
public boolean isSSL()
NetSocket
is encrypted via SSL/TLSpublic String scheme()
public String uri()
public String path()
public String query()
public String host()
public long bytesRead()
public HttpServerResponse response()
HttpServerResponse
instance attached to it. This is used to send the response back to the client.public MultiMap headers()
public String getHeader(String headerName)
headerName
- the header namepublic MultiMap params()
public String getParam(String paramName)
paramName
- the param namepublic SocketAddress remoteAddress()
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.public SocketAddress localAddress()
null
(e.g a server bound on a domain socket) If useProxyProtocol
is set to true
, the address returned will be of the proxy.public String absoluteURI()
public HttpServerRequest bodyHandler(Handler<Buffer> bodyHandler)
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.
bodyHandler
- This handler will be called after all the body has been receivedpublic HttpServerRequest body(Handler<AsyncResult<Buffer>> handler)
body(io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.core.buffer.Buffer>>)
but with an handler
called when the operation completeshandler
- public void end(Handler<AsyncResult<Void>> handler)
end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with an handler
called when the operation completeshandler
- public void end()
end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with an handler
called when the operation completespublic Single<Void> rxEnd()
end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with an handler
called when the operation completespublic void toNetSocket(Handler<AsyncResult<NetSocket>> handler)
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); }); } ... });
handler
- the completion handlerpublic void toNetSocket()
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); }); } ... });
public Single<NetSocket> rxToNetSocket()
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); }); } ... });
public HttpServerRequest setExpectMultipart(boolean expect)
expect
- true - if you are expecting a multi-part bodypublic boolean isExpectMultipart()
setExpectMultipart(boolean)
.public HttpServerRequest uploadHandler(Handler<HttpServerFileUpload> uploadHandler)
uploadHandler
- public MultiMap formAttributes()
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.
public String getFormAttribute(String attributeName)
attributeName
- the attribute namepublic int streamId()
public void toWebSocket(Handler<AsyncResult<ServerWebSocket>> handler)
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.
handler
- the completion handlerpublic void toWebSocket()
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.
public Single<ServerWebSocket> rxToWebSocket()
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.
public boolean isEnded()
public HttpServerRequest customFrameHandler(Handler<HttpFrame> handler)
handler
- public HttpConnection connection()
HttpConnection
associated with this requestpublic StreamPriority streamPriority()
null
public HttpServerRequest streamPriorityHandler(Handler<StreamPriority> handler)
This is not implemented for HTTP/1.x.
handler
- the handler to be called when stream priority changespublic Cookie getCookie(String name)
name
- the cookie namepublic int cookieCount()
public HttpServerRequest routed(String route)
route
- The route this request has been routed to.public String getHeader(CharSequence headerName)
headerName
- the header namepublic SSLSession sslSession()
public static HttpServerRequest newInstance(HttpServerRequest arg)
Copyright © 2021 Eclipse. All rights reserved.