Class HttpServerRequest
- All Implemented Interfaces:
MutinyDelegate,ReadStream<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 using Vert.x codegen.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionHttpServerRequest(io.vertx.core.http.HttpServerRequest delegate) HttpServerRequest(Object delegate) -
Method Summary
Modifier and TypeMethodDescriptionauthority(boolean real) io.smallrye.mutiny.Uni<Buffer>body()Same asbody()but with anhandlercalled when the operation completesBlocking variant ofbody().voidVariant ofbody()that ignores the result of the operation.bodyHandler(Consumer<Buffer> bodyHandler) longintDeprecated.the implementation made a wrong assumption that cookies could be identified only by their name.cookies()customFrameHandler(Consumer<HttpFrame> handler) io.smallrye.mutiny.Uni<Void>end()Same asend()but with anhandlercalled when the operation completesBlocking variant ofend().voidVariant ofend()that ignores the result of the operation.endHandler(Runnable endHandler) booleanexceptionHandler(Consumer<Throwable> handler) fetch(long amount) io.vertx.core.http.HttpServerRequestgetFormAttribute(String attributeName) getHeader(CharSequence headerName) inthashCode()headers()host()Deprecated.instead useauthority()booleanisEnded()booleanbooleanisSSL()io.vertx.core.http.HttpMethodmethod()static HttpServerRequestnewInstance(io.vertx.core.http.HttpServerRequest arg) params()params(boolean semicolonIsNormalChar) path()pause()pipe()io.smallrye.mutiny.Uni<Void>pipeTo(WriteStream<Buffer> dst) Pipe thisReadStreamto theWriteStream.pipeToAndAwait(WriteStream<Buffer> dst) Blocking variant ofReadStream.pipeTo(io.vertx.mutiny.core.streams.WriteStream).voidpipeToAndForget(WriteStream<Buffer> dst) Variant ofReadStream.pipeTo(io.vertx.mutiny.core.streams.WriteStream)that ignores the result of the operation.query()response()resume()scheme()setExpectMultipart(boolean expect) setParamsCharset(String charset) intstreamId()io.vertx.core.http.StreamPrioritystreamPriorityHandler(Consumer<io.vertx.core.http.StreamPriority> handler) io.smallrye.mutiny.Multi<Buffer>toMulti()io.smallrye.mutiny.Uni<NetSocket>Establish a TCP tunnel with the client.Blocking variant oftoNetSocket().voidVariant oftoNetSocket()that ignores the result of the operation.toString()io.smallrye.mutiny.Uni<ServerWebSocket>Upgrade the connection of the current request to a WebSocket.Blocking variant oftoWebSocket().voidVariant oftoWebSocket()that ignores the result of the operation.uploadHandler(Consumer<HttpServerFileUpload> uploadHandler) uri()io.vertx.core.http.HttpVersionversion()
-
Field Details
-
__TYPE_ARG
-
-
Constructor Details
-
HttpServerRequest
public HttpServerRequest(io.vertx.core.http.HttpServerRequest delegate) -
HttpServerRequest
-
-
Method Details
-
getDelegate
public io.vertx.core.http.HttpServerRequest getDelegate()- Specified by:
getDelegatein interfaceMutinyDelegate- Specified by:
getDelegatein interfaceReadStream<Buffer>- Specified by:
getDelegatein interfaceStreamBase- Returns:
- the delegate used by this Mutiny object of generated type
-
toString
-
equals
-
hashCode
public int hashCode() -
pipe
- Specified by:
pipein interfaceReadStream<Buffer>- Returns:
- a pipe
-
pipeTo
Pipe thisReadStreamto theWriteStream.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
handlerwill be called with the result.Unlike the bare Vert.x variant, this method returns a
Uni. Don't forget to subscribe on it to trigger the operation.- Specified by:
pipeToin interfaceReadStream<Buffer>- Parameters:
dst- the destination write stream- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
pipeToAndAwait
Blocking variant ofReadStream.pipeTo(io.vertx.mutiny.core.streams.WriteStream).This method waits 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 a RuntimeException).
- Specified by:
pipeToAndAwaitin interfaceReadStream<Buffer>- Parameters:
dst- the destination write stream- Returns:
- the Void instance produced by the operation.
-
pipeToAndForget
Variant ofReadStream.pipeTo(io.vertx.mutiny.core.streams.WriteStream)that ignores the result of the operation.This method subscribes on the result of
ReadStream.pipeTo(io.vertx.mutiny.core.streams.WriteStream), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromReadStream.pipeTo(io.vertx.mutiny.core.streams.WriteStream)but you don't need to compose it with other operations.- Specified by:
pipeToAndForgetin interfaceReadStream<Buffer>- Parameters:
dst- the destination write stream
-
exceptionHandler
- Specified by:
exceptionHandlerin interfaceReadStream<Buffer>- Specified by:
exceptionHandlerin interfaceStreamBase- Parameters:
handler- the exception handler- Returns:
-
handler
- Specified by:
handlerin interfaceReadStream<Buffer>- Returns:
-
pause
- Specified by:
pausein interfaceReadStream<Buffer>- Returns:
- a reference to this, so the API can be used fluently
-
resume
- Specified by:
resumein interfaceReadStream<Buffer>- Returns:
- a reference to this, so the API can be used fluently
-
fetch
- Specified by:
fetchin interfaceReadStream<Buffer>- Returns:
- a reference to this, so the API can be used fluently
-
endHandler
- Specified by:
endHandlerin interfaceReadStream<Buffer>- Returns:
-
version
public io.vertx.core.http.HttpVersion version()- Returns:
- the HTTP version of the request
-
method
public io.vertx.core.http.HttpMethod method()- 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
-
uri
- Returns:
- the URI of the request. This is usually a relative URI
-
path
- Returns:
- The path part of the uri. For example /somepath/somemorepath/someresource.foo
-
query
- Returns:
- the query part of the uri. For example someparam=32&someotherparam=x
-
authority
- Returns:
- the request authority.
- HTTP/2: the pseudo header is returned if present, otherwise the header value is returned.
- HTTP/1.x: the header is returned
- or
nullwhen no such header is present
-1to indicate the scheme port is prevalent.
-
authority
- Parameters:
real- whether to return the value of the real HTTP/2 header, or the computed one.- Returns:
- the authority, either computed or real. May be null when is
true.
-
host
Deprecated.instead useauthority()- 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
- 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.
-
headers
- Returns:
- the headers in the request.
-
getHeader
- Parameters:
headerName- the header name- Returns:
- the header value
-
setParamsCharset
- 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
- Returns:
- the query parameters in the request
-
params
- Parameters:
semicolonIsNormalChar- whether semicolon is treated as a normal character or a query parameter separator- Returns:
- the query parameters in the request
-
getParam
- Parameters:
paramName- the param name- Returns:
- the param value
-
getParam
- Parameters:
paramName- the param namedefaultValue- the default value, must be non-null- Returns:
- the param value or
defaultValuewhen not present
-
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
- 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.
-
absoluteURI
- Returns:
- the absolute URI corresponding to the HTTP request
-
bodyHandler
- Parameters:
bodyHandler- This handler will be called after all the body has been received- Returns:
-
body
Same asbody()but with anhandlercalled when the operation completesUnlike the bare Vert.x variant, this method returns a
Uni. Don't forget to subscribe on it to trigger the operation.- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
bodyAndAwait
Blocking variant ofbody().This method waits 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 a RuntimeException).
- Returns:
- the Buffer instance produced by the operation.
-
bodyAndForget
public void bodyAndForget() -
end
Same asend()but with anhandlercalled when the operation completesUnlike the bare Vert.x variant, this method returns a
Uni. Don't forget to subscribe on it to trigger the operation.- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
endAndAwait
Blocking variant ofend().This method waits 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 a RuntimeException).
- Returns:
- the Void instance produced by the operation.
-
endAndForget
public void endAndForget() -
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. Don't forget to subscribe on it to trigger the operation.- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
toNetSocketAndAwait
Blocking variant oftoNetSocket().This method waits 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 a RuntimeException).
- Returns:
- the NetSocket instance produced by the operation.
-
toNetSocketAndForget
public void toNetSocketAndForget()Variant oftoNetSocket()that ignores the result of the operation.This method subscribes on the result of
toNetSocket(), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromtoNetSocket()but you don't need to compose it with other operations. -
setExpectMultipart
- 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
- Parameters:
uploadHandler-- Returns:
-
formAttributes
- Returns:
- the form attributes
-
getFormAttribute
- 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
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(java.util.function.Consumer<io.vertx.mutiny.core.buffer.Buffer>)andendHandler(java.lang.Runnable)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. Don't forget to subscribe on it to trigger the operation.- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
toWebSocketAndAwait
Blocking variant oftoWebSocket().This method waits 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 a RuntimeException).
- Returns:
- the ServerWebSocket instance produced by the operation.
-
toWebSocketAndForget
public void toWebSocketAndForget()Variant oftoWebSocket()that ignores the result of the operation.This method subscribes on the result of
toWebSocket(), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromtoWebSocket()but you don't need to compose it with other operations. -
isEnded
public boolean isEnded()- Returns:
- true if ended
-
customFrameHandler
- Parameters:
handler-- Returns:
-
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
- Parameters:
handler- the handler to be called when stream priority changes- Returns:
-
getCookie
- Parameters:
name- the cookie name- Returns:
- the cookie or
nullif not found.
-
getCookie
- 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.
-
cookieMap
Deprecated.the implementation made a wrong assumption that cookies could be identified only by their name. The RFC states that the tuple of<name, domain, path>is the unique identifier. When more than one cookie has the same name, the map will hold that lost one to be parsed and any previously parsed value will be silently overwritten.- Returns:
- a map of all the cookies.
-
cookies
- Parameters:
name- the name to be matches- Returns:
- the matching cookies or empty set
-
cookies
- Returns:
- a set with all cookies in the cookie jar.
-
routed
- Parameters:
route- The route this request has been routed to.- Returns:
- the instance of HttpServerRequest to chain method calls.
-
getHeader
- Parameters:
headerName- the header name- Returns:
- the header value
-
sslSession
- Returns:
- SSLSession associated with the underlying socket. Returns null if connection is not SSL.
-
toMulti
- Specified by:
toMultiin interfaceReadStream<Buffer>
-
toBlockingIterable
-
toBlockingStream
-
newInstance
-