Class HttpServerRequest
- java.lang.Object
-
- io.vertx.mutiny.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
HttpServerResponseinstance viaresponse().It implements
ReadStreamso it can be used withPumpto pump data with flow control.
NOTE: This class has been automatically generated from theoriginalnon Mutiny-ified interface using Vert.x codegen.
-
-
Field Summary
Fields Modifier and Type Field Description static TypeArg<HttpServerRequest>__TYPE_ARG
-
Constructor Summary
Constructors Constructor Description HttpServerRequest(io.vertx.core.http.HttpServerRequest delegate)
-
Method Summary
-
-
-
Field Detail
-
__TYPE_ARG
public static final TypeArg<HttpServerRequest> __TYPE_ARG
-
-
Method Detail
-
getDelegate
public io.vertx.core.http.HttpServerRequest getDelegate()
- Specified by:
getDelegatein interfaceReadStream<Buffer>- Specified by:
getDelegatein interfaceStreamBase
-
pipe
public Pipe<Buffer> pipe()
- Specified by:
pipein interfaceReadStream<Buffer>- Returns:
- a pipe
-
pipeTo
public io.smallrye.mutiny.Uni<Void> pipeTo(WriteStream<Buffer> dst)
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
public Void pipeToAndAwait(WriteStream<Buffer> dst)
Blocking variant ofio.vertx.mutiny.core.streams.ReadStream#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
-
exceptionHandler
public HttpServerRequest exceptionHandler(Consumer<Throwable> handler)
- Specified by:
exceptionHandlerin interfaceReadStream<Buffer>- Specified by:
exceptionHandlerin interfaceStreamBase- Parameters:
handler- the exception handler- Returns:
- a reference to this, so the API can be used fluently
-
handler
public HttpServerRequest handler(Consumer<Buffer> handler)
- Specified by:
handlerin interfaceReadStream<Buffer>- Returns:
- a reference to this, so the API can be used fluently
-
pause
public HttpServerRequest pause()
- Specified by:
pausein interfaceReadStream<Buffer>- Returns:
- a reference to this, so the API can be used fluently
-
resume
public HttpServerRequest resume()
- Specified by:
resumein interfaceReadStream<Buffer>- Returns:
- a reference to this, so the API can be used fluently
-
fetch
public HttpServerRequest fetch(long amount)
- Specified by:
fetchin interfaceReadStream<Buffer>- Returns:
- a reference to this, so the API can be used fluently
-
endHandler
public HttpServerRequest endHandler(Consumer<Void> endHandler)
- Specified by:
endHandlerin interfaceReadStream<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()
- Returns:
- the HTTP method for the request.
-
rawMethod
public String rawMethod()
- Returns:
- the HTTP method as sent by the client
-
isSSL
public boolean isSSL()
- Returns:
- true if this
NetSocketis 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
HttpServerResponseinstance 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)
- 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)
- Parameters:
paramName- the param name- Returns:
- the param value
-
remoteAddress
public SocketAddress remoteAddress()
- Returns:
- the remote address for this connection, possibly
null(e.g a server bound on a domain socket)
-
localAddress
public SocketAddress localAddress()
- Returns:
- the local address for this connection, possibly
null(e.g a server bound on a domain socket)
-
absoluteURI
public String absoluteURI()
- Returns:
- the absolute URI corresponding to the the HTTP request
-
bodyHandler
public HttpServerRequest bodyHandler(Consumer<Buffer> bodyHandler)
- Parameters:
bodyHandler- This handler will be called after all the body has been received- Returns:
-
netSocket
@Deprecated public NetSocket netSocket()
Deprecated.- Returns:
- the net socket
-
toNetSocket
public io.smallrye.mutiny.Uni<NetSocket> toNetSocket()
Establish a TCP tunnel with the client.This must be called only for
CONNECTHTTP method and before any response is sent.Calling this sends a
200response with 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
public NetSocket 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
-
setExpectMultipart
public HttpServerRequest setExpectMultipart(boolean expect)
- 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(Consumer<HttpServerFileUpload> uploadHandler)
- Parameters:
uploadHandler-- Returns:
- a reference to this, so the API can be used fluently
-
formAttributes
public MultiMap formAttributes()
- Returns:
- the form attributes
-
getFormAttribute
public String getFormAttribute(String attributeName)
- 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
-
upgrade
@Deprecated public ServerWebSocket upgrade()
Deprecated.- Returns:
- the WebSocket
-
toWebSocket
public io.smallrye.mutiny.Uni<ServerWebSocket> 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.util.function.Consumer<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.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
public ServerWebSocket 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
-
isEnded
public boolean isEnded()
- Returns:
- true if ended
-
customFrameHandler
public HttpServerRequest customFrameHandler(Consumer<HttpFrame> handler)
- Parameters:
handler-- Returns:
- a reference to this, so the API can be used fluently
-
connection
public HttpConnection 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
public HttpServerRequest streamPriorityHandler(Consumer<io.vertx.core.http.StreamPriority> handler)
- Parameters:
handler- the handler to be called when stream priority changes- Returns:
-
getCookie
public Cookie getCookie(String name)
- Parameters:
name- the cookie name- Returns:
- the cookie
-
cookieCount
public int cookieCount()
- Returns:
- the number of cookieMap.
-
getHeader
public String getHeader(CharSequence headerName)
- 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.
-
pipeToAndForget
public void pipeToAndForget(WriteStream<Buffer> dst)
Variant ofio.vertx.mutiny.core.streams.ReadStream#pipeTo(io.vertx.mutiny.core.streams.WriteStreamthat ignores the result of the operation.) This method subscribes on the result of
io.vertx.mutiny.core.streams.ReadStream#pipeTo(io.vertx.mutiny.core.streams.WriteStream, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from) io.vertx.mutiny.core.streams.ReadStream#pipeTo(io.vertx.mutiny.core.streams.WriteStreambut you don't need to compose it with other operations.) - Parameters:
dst-
-
toMulti
public io.smallrye.mutiny.Multi<Buffer> toMulti()
- Specified by:
toMultiin interfaceReadStream<Buffer>
-
newInstance
public static HttpServerRequest newInstance(io.vertx.core.http.HttpServerRequest arg)
-
-