Same as {@link HttpServerRequest#body} but with an handler
called when the operation completes
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.
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.
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.
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.
Same as {@link HttpServerRequest#end} but with an handler
called when the operation completes
Same as {@link HttpServerRequest#end} but with an handler
called when the operation completes
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.
{@link HttpServerRequest#setExpectMultipart} must be called first before trying to get the form attributes.
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: {@link HttpServerRequest#cookies}
Get the cookie with the specified
.
Return the first form attribute value with the specified name
Return the first header value with the specified name
Return the first header value with the specified name
Return the first param value with the specified name
Return the first param value with the specified name or defaultValue
when the query param is not present
Has the request ended? I.e. has the entire request, including the body been read?
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.
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.
Marks this request as being routed to the given route. This is purely informational and is being provided to metrics.
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
Override the charset to use for decoding the query parameter map, when none is set, UTF8
is used.
Set an handler for stream priority changes
This is not implemented for HTTP/1.x.
Establish a TCP tunnel with the client.
This must be called only for CONNECT
HTTP method or for HTTP connection upgrade, before any response is sent.
Calling this sends a 200
response for a CONNECT
or a 101
for a connection upgrade wit
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); }); } ... });
Establish a TCP tunnel with the client.
This must be called only for CONNECT
HTTP method or for HTTP connection upgrade, before any response is sent.
Calling this sends a 200
response for a CONNECT
or a 101
for a connection upgrade wit
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); }); } ... });
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 {@link HttpServerRequest#handler} and {@link HttpServerRequest#endHandler} 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 {@link HttpServerRequest#pause} the request in order to not lose HTTP events necessary to upgrade the request.
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 {@link HttpServerRequest#handler} and {@link HttpServerRequest#endHandler} 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 {@link HttpServerRequest#pause} the request in order to not lose HTTP events necessary to upgrade the request.
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.
Generated using TypeDoc
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 {@link HttpServerRequest#response}.
It implements ReadStream so it can be used with Pipe to pipe data with flow control.