Class HttpServerRequest
- All Implemented Interfaces:
MutinyDelegate,ReadStream<io.vertx.core.buffer.Buffer>,StreamBase
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 Mutiny-ified interface.
- Author:
- Tim Fox
- See Also:
-
HttpServerRequest
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.vertx.mutiny.core.streams.ReadStream
ReadStream.ReadStreamImpl<T>Nested classes/interfaces inherited from interface io.vertx.mutiny.core.streams.StreamBase
StreamBase.StreamBaseImpl -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionHttpServerRequest(io.vertx.core.http.HttpServerRequest delegate) Create a new instance ofHttpServerRequestdelegating to the given (non-null) instance ofHttpServerRequest.HttpServerRequest(Object delegate) -
Method Summary
Modifier and TypeMethodDescriptionio.vertx.core.net.HostAndPortio.vertx.core.net.HostAndPortauthority(boolean real) io.smallrye.mutiny.Uni<io.vertx.core.buffer.Buffer>body()Convenience method for receiving the entire request body in one piece.io.vertx.core.buffer.BufferConvenience method for receiving the entire request body in one piece.Convenience method for receiving the entire request body in one piece.bodyHandler(Consumer<io.vertx.core.buffer.Buffer> bodyHandler) Convenience method for receiving the entire request body in one piece.longbooleanintSet<io.vertx.core.http.Cookie>cookies()Returns a modifiable set of parsed cookies from theCOOKIEheader.Set<io.vertx.core.http.Cookie>Returns a read only set of parsed cookies that match the given name, or an empty set.customFrameHandler(Consumer<io.vertx.core.http.HttpFrame> handler) Set a custom frame handler.io.smallrye.mutiny.Uni<Void>end()Returns a uni signaling when the request has been fully received successfully or failed.voidReturns a underlying uni signaling when the request has been fully received successfully or failed.Returns a underlying uni signaling when the request has been fully received successfully or failed.endHandler(Runnable endHandler) Set an end handler.booleanexceptionHandler(Consumer<Throwable> handler) Set an exception handler on the read stream.fetch(long amount) Fetch the specifiedamountof elements.io.vertx.core.MultiMapReturns a map of all form attributes in the request.io.vertx.core.http.CookieGet the cookie with the specified name.io.vertx.core.http.CookieGet the cookie with the specified<name, domain, path>.io.vertx.core.http.HttpServerRequestGet the delegate instance.getFormAttribute(String attributeName) Return the first form attribute value with the specified nameReturn the first param value with the specified nameReturn the first param value with the specified name ordefaultValuewhen the query param is not presentSet a data handler.inthashCode()booleanisEnded()Has the request ended?booleanbooleanisSSL()io.vertx.core.net.SocketAddressio.vertx.core.http.HttpMethodmethod()static HttpServerRequestnewInstance(io.vertx.core.http.HttpServerRequest delegate) Creates a new instance of theHttpServerRequest.io.vertx.core.MultiMapparams()io.vertx.core.MultiMapparams(boolean semicolonIsNormalChar) pause()Pause theReadStream, it sets the buffer infetchmode and clears the actual demand.Pipe<io.vertx.core.buffer.Buffer>pipe()Pause this stream and return aPipeto transfer the elements of this stream to a destinationWriteStream.io.smallrye.mutiny.Uni<Void>pipeTo(WriteStream<io.vertx.core.buffer.Buffer> arg0) Pipe thisReadStreamto theWriteStream.voidpipeToAndAwait(WriteStream<io.vertx.core.buffer.Buffer> arg0) Pipe thisReadStreamto theWriteStream.pipeToAndForget(WriteStream<io.vertx.core.buffer.Buffer> arg0) Pipe thisReadStreamto theWriteStream.io.vertx.core.net.SocketAddressresponse()resume()Resume reading, and sets the buffer inflowingmode.Marks this request as being routed to the given route.scheme()setExpectMultipart(boolean expect) Call this with true if you are expecting a multi-part body to be submitted in the request.setParamsCharset(String charset) Override the charset to use for decoding the query parameter map, when none is set,UTF8is used.longstreamId()io.vertx.core.http.StreamPrioritystreamPriorityHandler(Consumer<io.vertx.core.http.StreamPriority> handler) Set an handler for stream priority changesIterable<io.vertx.core.buffer.Buffer>Stream<io.vertx.core.buffer.Buffer>io.smallrye.mutiny.Multi<io.vertx.core.buffer.Buffer>toMulti()io.smallrye.mutiny.Uni<NetSocket>Establish a TCP tunnel with the client.Establish a TCP tunnel with the client.Establish a TCP tunnel with the client.toString()io.smallrye.mutiny.Uni<ServerWebSocket>Upgrade the connection of the current request to a WebSocket.Upgrade the connection of the current request to a WebSocket.Upgrade the connection of the current request to a WebSocket.uploadHandler(Consumer<HttpServerFileUpload> uploadHandler) Set an upload handler.io.vertx.core.http.HttpVersionversion()Methods inherited from class io.vertx.mutiny.core.http.HttpRequestHead
getHeader, getHeader, headers, newInstance, path, query, uri
-
Field Details
-
__TYPE_ARG
-
-
Constructor Details
-
HttpServerRequest
public HttpServerRequest(io.vertx.core.http.HttpServerRequest delegate) Create a new instance ofHttpServerRequestdelegating to the given (non-null) instance ofHttpServerRequest. -
HttpServerRequest
-
-
Method Details
-
getDelegate
public io.vertx.core.http.HttpServerRequest getDelegate()Get the delegate instance.This method returns the instance on which this shim is delegating the calls. And so, give you access to the bare API.
- Specified by:
getDelegatein interfaceMutinyDelegate- Specified by:
getDelegatein interfaceReadStream<io.vertx.core.buffer.Buffer>- Specified by:
getDelegatein interfaceStreamBase- Overrides:
getDelegatein classHttpRequestHead- Returns:
- the delegate instance
-
body
@CheckReturnValue public io.smallrye.mutiny.Uni<io.vertx.core.buffer.Buffer> body()Convenience method for receiving the entire request body in one piece.This saves you having to manually set a dataHandler and an endHandler 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.
Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
HttpServerRequest.body()
-
bodyAndAwait
public io.vertx.core.buffer.Buffer bodyAndAwait()Convenience method for receiving the entire request body in one piece.This saves you having to manually set a dataHandler and an endHandler 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.
Unlike the bare Vert.x variant, this method returns a
Buffer. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- Returns:
- The operation result
- See Also:
-
HttpServerRequest.body()
-
bodyAndForget
Convenience method for receiving the entire request body in one piece.This saves you having to manually set a dataHandler and an endHandler 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.
Unlike the bare Vert.x variant, this method ignores the
Bufferresult or any failure.- Returns:
- The current instance to chain operations if needed.
- See Also:
-
HttpServerRequest.body()
-
end
Returns a uni signaling when the request has been fully received successfully or failed.Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
HttpServerRequest.end()
-
endAndAwait
public void endAndAwait()Returns a underlying uni signaling when the request has been fully received successfully or failed.Unlike the bare Vert.x variant, this method returns a
Void. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- See Also:
-
HttpServerRequest.end()
-
endAndForget
Returns a underlying uni signaling when the request has been fully received successfully or failed.Unlike the bare Vert.x variant, this method ignores the
Voidresult or any failure.- Returns:
- The current instance to chain operations if needed.
- See Also:
-
HttpServerRequest.end()
-
toNetSocket
Establish a TCP tunnel with the client.This must be called only for
CONNECTHTTP method or for HTTP connection upgrade, before any response is sent.Calling this sends a
200response for aCONNECTor a101for a connection upgrade wit nocontent-lengthheader set and then provides theNetSocketfor 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); }); } ... });Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
HttpServerRequest.toNetSocket()
-
toNetSocketAndAwait
Establish a TCP tunnel with the client.This must be called only for
CONNECTHTTP method or for HTTP connection upgrade, before any response is sent.Calling this sends a
200response for aCONNECTor a101for a connection upgrade wit nocontent-lengthheader set and then provides theNetSocketfor 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); }); } ... });Unlike the bare Vert.x variant, this method returns a
NetSocket. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- Returns:
- The operation result
- See Also:
-
HttpServerRequest.toNetSocket()
-
toNetSocketAndForget
Establish a TCP tunnel with the client.This must be called only for
CONNECTHTTP method or for HTTP connection upgrade, before any response is sent.Calling this sends a
200response for aCONNECTor a101for a connection upgrade wit nocontent-lengthheader set and then provides theNetSocketfor 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); }); } ... });Unlike the bare Vert.x variant, this method ignores the
NetSocketresult or any failure.- Returns:
- The current instance to chain operations if needed.
- See Also:
-
HttpServerRequest.toNetSocket()
-
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(Handler)and#endHandler(Handler)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.Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
HttpServerRequest.toWebSocket()
-
toWebSocketAndAwait
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(Handler)and#endHandler(Handler)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.Unlike the bare Vert.x variant, this method returns a
ServerWebSocket. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- Returns:
- The operation result
- See Also:
-
HttpServerRequest.toWebSocket()
-
toWebSocketAndForget
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(Handler)and#endHandler(Handler)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.Unlike the bare Vert.x variant, this method ignores the
ServerWebSocketresult or any failure.- Returns:
- The current instance to chain operations if needed.
- See Also:
-
HttpServerRequest.toWebSocket()
-
pipeTo
@CheckReturnValue public io.smallrye.mutiny.Uni<Void> pipeTo(WriteStream<io.vertx.core.buffer.Buffer> arg0) Pipe thisReadStreamto theWriteStream.Elements emitted by this stream will be written to the write stream until this stream ends or fails.
Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Specified by:
pipeToin interfaceReadStream<io.vertx.core.buffer.Buffer>- Parameters:
dst- the destination write stream- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
io.vertx.core.http.HttpServerRequest#pipeTo(WriteStream)
-
pipeToAndAwait
Pipe thisReadStreamto theWriteStream.Elements emitted by this stream will be written to the write stream until this stream ends or fails.
Unlike the bare Vert.x variant, this method returns a
Void. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- Parameters:
dst- the destination write stream- See Also:
-
io.vertx.core.http.HttpServerRequest#pipeTo(WriteStream)
-
pipeToAndForget
Pipe thisReadStreamto theWriteStream.Elements emitted by this stream will be written to the write stream until this stream ends or fails.
Unlike the bare Vert.x variant, this method ignores the
Voidresult or any failure.- Parameters:
dst- the destination write stream- Returns:
- The current instance to chain operations if needed.
- See Also:
-
io.vertx.core.http.HttpServerRequest#pipeTo(WriteStream)
-
exceptionHandler
Description copied from interface:ReadStreamSet an exception handler on the read stream.- Specified by:
exceptionHandlerin interfaceReadStream<io.vertx.core.buffer.Buffer>- Specified by:
exceptionHandlerin interfaceStreamBase- Parameters:
handler- the exception handler. Can benull.- Returns:
- a reference to this, so the API can be used fluently
-
handler
Description copied from interface:ReadStreamSet a data handler. As data is read, the handler will be called with the data.- Specified by:
handlerin interfaceReadStream<io.vertx.core.buffer.Buffer>- Returns:
- a reference to this, so the API can be used fluently
-
pause
Description copied from interface:ReadStreamPause theReadStream, it sets the buffer infetchmode and clears the actual demand.While it's paused, no data will be sent to the data
handler.- Specified by:
pausein interfaceReadStream<io.vertx.core.buffer.Buffer>- Returns:
- a reference to this, so the API can be used fluently
-
resume
Description copied from interface:ReadStreamResume reading, and sets the buffer inflowingmode. If theReadStreamhas been paused, reading will recommence on it.- Specified by:
resumein interfaceReadStream<io.vertx.core.buffer.Buffer>- Returns:
- a reference to this, so the API can be used fluently
-
fetch
Description copied from interface:ReadStreamFetch the specifiedamountof elements. If theReadStreamhas been paused, reading will recommence with the specifiedamountof items, otherwise the specifiedamountwill be added to the current stream demand.- Specified by:
fetchin interfaceReadStream<io.vertx.core.buffer.Buffer>- Returns:
- a reference to this, so the API can be used fluently
-
endHandler
Description copied from interface:ReadStreamSet an end handler. Once the stream has ended, and there is no more data to be read, this handler will be called.- Specified by:
endHandlerin interfaceReadStream<io.vertx.core.buffer.Buffer>- Returns:
- a reference to this, so the API can be used fluently
-
version
public io.vertx.core.http.HttpVersion version()- Returns:
- the HTTP version of the request
-
method
public io.vertx.core.http.HttpMethod method()- Overrides:
methodin classHttpRequestHead- Returns:
- the HTTP method for the request.
-
isSSL
public boolean isSSL()- Returns:
- true if this
NetSocketis encrypted via SSL/TLS
-
scheme
- Returns:
- the scheme of the request. Can be
null.
-
authority
public io.vertx.core.net.HostAndPort authority()- Returns:
- the request authority.
- HTTP/2: the :authority pseudo header is returned if present, otherwise the Host header value is returned.
- HTTP/1.x: the Host header is returned
- or
nullwhen no such header is present
HostAndPort.port()returns-1to indicate the scheme port is prevalent.
-
authority
public io.vertx.core.net.HostAndPort authority(boolean real) - Parameters:
real- whether to return the value of the real HTTP/2 :authority header, or the computed one.- Returns:
- the authority, either computed or real. May be null when real is
true.
-
bytesRead
public long bytesRead()- Returns:
- the total number of bytes read for the body of the request.
-
response
- Returns:
- the response. Each instance of this class has an
HttpServerResponseinstance attached to it. This is used to send the response back to the client.
-
setParamsCharset
Override the charset to use for decoding the query parameter map, when none is set,UTF8is used.- Parameters:
charset- the charset to use for decoding query params- Returns:
- a reference to this, so the API can be used fluently
-
getParamsCharset
- Returns:
- the charset used for decoding query parameters
-
params
public io.vertx.core.MultiMap params()- Returns:
- the query parameters in the request
-
params
public io.vertx.core.MultiMap params(boolean semicolonIsNormalChar) - Parameters:
semicolonIsNormalChar- whether semicolon is treated as a normal character or a query parameter separator- Returns:
- the query parameters in the request
-
getParam
Return the first param value with the specified name- Parameters:
paramName- the param name- Returns:
- the param value. Can be
null.
-
getParam
Return the first param value with the specified name ordefaultValuewhen the query param is not present- Parameters:
paramName- the param namedefaultValue- the default value, must be non-null- Returns:
- the param value or
defaultValuewhen not present
-
remoteAddress
public io.vertx.core.net.SocketAddress remoteAddress()- Returns:
- the remote address for this connection, possibly
null(e.g a server bound on a domain socket). IfuseProxyProtocolis set totrue, the address returned will be of the actual connecting client.
-
localAddress
public io.vertx.core.net.SocketAddress localAddress()- Returns:
- the local address for this connection, possibly
null(e.g a server bound on a domain socket) IfuseProxyProtocolis set totrue, the address returned will be of the proxy.
-
sslSession
- Returns:
- SSLSession associated with the underlying socket. Returns null if connection is not SSL.
- See Also:
-
absoluteURI
- Returns:
- the absolute URI corresponding to the HTTP request
-
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. Can benull.
-
setExpectMultipart
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
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.- Returns:
- a reference to this, so the API can be used fluently
-
formAttributes
public io.vertx.core.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
Return the first form attribute value with the specified name- Parameters:
attributeName- the attribute name- Returns:
- the attribute value. Can be
null.
-
streamId
public long streamId()- Returns:
- the id of the stream of this request, -1 when it is not yet determined, i.e the request has not been yet sent or it is not supported HTTP/1.x
-
canUpgradeToWebSocket
public boolean canUpgradeToWebSocket()- Returns:
- whether this request can be upgraded to a WebSocket, implying it uses HTTP/1.x and presents the correct characteristics for a proper upgrade.
-
isEnded
public boolean isEnded()Has the request ended? I.e. has the entire request, including the body been read?- Returns:
- true if ended
-
customFrameHandler
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.- Returns:
- a reference to this, so the API can be used fluently
-
connection
- Returns:
- the
HttpConnectionassociated with this request
-
streamPriority
public io.vertx.core.http.StreamPriority streamPriority()- Returns:
- the priority of the associated HTTP/2 stream for HTTP/2 otherwise
null
-
streamPriorityHandler
Set an handler for stream priority changesThis is not implemented for HTTP/1.x.
- Parameters:
handler- the handler to be called when stream priority changes
-
getCookie
Get the cookie with the specified name. NOTE: this will return just the 1stCookiethat matches the given name, to get all cookies for this name see:cookies(String)- Parameters:
name- the cookie name- Returns:
- the cookie or
nullif not found.
-
getCookie
Get the cookie with the specified<name, domain, path>.- Parameters:
name- the cookie namedomain- the cookie domainpath- the cookie path- Returns:
- the cookie or
nullif not found.
-
cookieCount
public int cookieCount()- Returns:
- the number of cookies in the cookie jar.
-
cookies
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<name, domain, path>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 returnedSetis read-only. This means any attempt to modify (add or remove to the set), will throwUnsupportedOperationException.- Parameters:
name- the name to be matches- Returns:
- the matching cookies or empty set
-
cookies
Returns a modifiable set of parsed cookies from theCOOKIEheader. Several cookies may share the same name but have different keys. A cookie is unique by its<name, domain, path>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
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.
-
pipe
Pause this stream and return aPipeto transfer the elements of this stream to a destinationWriteStream. The stream will be resumed when the pipe will be wired to aWriteStream.- Specified by:
pipein interfaceReadStream<io.vertx.core.buffer.Buffer>- Returns:
- a pipe
-
newInstance
Creates a new instance of theHttpServerRequest. -
hashCode
public int hashCode()- Overrides:
hashCodein classHttpRequestHead
-
equals
- Overrides:
equalsin classHttpRequestHead
-
toString
- Overrides:
toStringin classHttpRequestHead
-
toMulti
@CheckReturnValue public io.smallrye.mutiny.Multi<io.vertx.core.buffer.Buffer> toMulti() -
toBlockingIterable
-
toBlockingStream
-