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 io. so it can be used with
io. to pipe data with flow control.
| Modifier and Type | Field and Description |
|---|---|
| public static final Handler | DEFAULT_INVALID_REQUEST_HANDLER
The default invalid request handler, it uses the |
| Modifier and Type | Method and Description |
|---|---|
| public String | |
| public @Nullable HostAndPort | Returns: the request authority. For HTTP/2 the :authority pseudo header is returned, for HTTP/1.x the Host header is returned ornull when no such header is present. When the authority
string does not carry a port, the HostAndPort#port() returns -1 to indicate the
scheme port is prevalent.
|
| public default HttpServerRequest | body(Handler<AsyncResult<Buffer>> handler)
Same as |
| public Future | Returns: a future completed with the body resultConvenience method for receiving the entire request body in one piece. |
| public default HttpServerRequest | bodyHandler(@Nullable Handler<Buffer>
This handler will be called after all the body has been received bodyHandler)Convenience method for receiving the entire request body in one piece. |
| public long | |
| public HttpConnection | |
| public default int | |
| public default Map | Returns: a map of all the cookies.
Deprecated
the implementation made a wrong assumption that cookies could be identified only by their name.
|
| public Set | |
| public Set | Returns: a set with all cookies in the cookie jar.Returns a modifiable set of parsed cookies from the |
| public HttpServerRequest | Returns: a reference to this, so the API can be used fluentlySet a custom frame handler. |
| public DecoderResult | Returns: Netty's decoder result useful for handling invalid requests withHttpServer#invalidRequestHandler
|
| public default void | end(Handler<AsyncResult<Void>> handler)
Same as |
| public Future | Returns: a future completed with the body resultReturns a future signaling when the request has been fully received successfully or failed. |
| public HttpServerRequest | |
| public HttpServerRequest | |
| public HttpServerRequest | fetch(long amount)
Redeclares io. Fetch the specified |
| public MultiMap | |
| public @Nullable Cookie | |
| public @Nullable Cookie | |
| public @Nullable String | Returns: the attribute valuethe attribute name attributeName)Return the first form attribute value with the specified name |
| public default @Nullable String | |
| public default String | Returns: the header valuethe header name headerName)Return the first header value with the specified name |
| public default @Nullable String | |
| public default String | |
| public String | |
| public HttpServerRequest | |
| public MultiMap | |
| public @Nullable String | Returns: the request host. For HTTP2 it returns the :authority pseudo header otherwise it returns the Host header
Deprecated
instead use
authority()
|
| public boolean | |
| public boolean | Returns: true if we are expecting a multi-part body for this request. SeesetExpectMultipart.
|
| public default boolean | |
| public default SocketAddress | Returns: the local address for this connection, possiblynull (e.g a server bound on a domain socket)
If useProxyProtocol is set to true, the address returned will be of the proxy.
|
| public HttpMethod | |
| public default MultiMap | |
| public MultiMap | Returns: the query parameters in the requestwhether semicolon is treated as a normal character or a query parameter separator semicolonIsNormalChar)
|
| public @Nullable String | |
| public HttpServerRequest | pause()
Redeclares io. Pause the |
| public X509Certificate[] | Returns: an ordered array of the peer certificates. Returns null if connection is not SSL.
References Deprecated
X509Certificate is deprecated or references (maybe indirectly) at least one deprecated element.
Note Java SE 5+ recommends to use javax.net.ssl.SSLSession#getPeerCertificates() instead of of javax.net.ssl.SSLSession#getPeerCertificateChain() which this method is based on. |
| public @Nullable String | |
| public default SocketAddress | Returns: the remote address for this connection, possiblynull (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 HttpServerResponse | Returns: the response. Each instance of this class has anHttpServerResponse instance attached to it. This is used
to send the response back to the client.
|
| public HttpServerRequest | resume()
Redeclares io. Resume reading, and sets the buffer in |
| public default HttpServerRequest | |
| public @Nullable String | |
| public HttpServerRequest | Returns: a reference to this, so the API can be used fluentlytrue - if you are expecting a multi-part body expect)Call this with true if you are expecting a multi-part body to be submitted in the request. |
| public HttpServerRequest | Returns: a reference to this, so the API can be used fluentlythe charset to use for decoding query params charset)Override the charset to use for decoding the query parameter map, when none is set, |
| public default SSLSession | Returns: SSLSession associated with the underlying socket. Returns null if connection is not SSL.
|
| public default int | 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
|
| public default StreamPriority | |
| public HttpServerRequest | streamPriorityHandler(Handler<StreamPriority>
the handler to be called when stream priority changes handler)Set an handler for stream priority changes This is not implemented for HTTP/1.x. |
| public default void | toNetSocket(Handler<AsyncResult<NetSocket>>
the completion handler handler)Establish a TCP tunnel with the client. This must be called only for Calling this sends a
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 Future | |
| public default void | toWebSocket(Handler<AsyncResult<ServerWebSocket>>
the completion handler handler)Upgrade the connection of the current request to a WebSocket. |
| public Future | |
| public HttpServerRequest | Returns: a reference to this, so the API can be used fluentlySet an upload handler. |
| public String | |
| public HttpVersion |
| DEFAULT_INVALID_REQUEST_HANDLER | back to summary |
|---|---|
| public static final Handler<HttpServerRequest> DEFAULT_INVALID_REQUEST_HANDLER The default invalid request handler, it uses the
| |
| absoluteURI | back to summary |
|---|---|
public String absoluteURI()
| |
| authority | back to summary |
|---|---|
public @Nullable HostAndPort authority()
| |
| body | back to summary |
|---|---|
| public default HttpServerRequest body(Handler<AsyncResult<Buffer>> handler) Same as | |
| body | back to summary |
|---|---|
| public Future 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. | |
| bodyHandler | back to summary |
|---|---|
| public default HttpServerRequest bodyHandler(@Nullable Handler<Buffer> 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. | |
| bytesRead | back to summary |
|---|---|
public long bytesRead()
| |
| connection | back to summary |
|---|---|
public HttpConnection connection()
| |
| cookieCount | back to summary |
|---|---|
public default int cookieCount()
| |
| cookieMap | back to summary |
|---|---|
| public default Map Deprecated the implementation made a wrong assumption that cookies could be identified only by their name. The RFC
states that the tuple of | |
| cookies | back to summary |
|---|---|
| public Set 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 Note the returned | |
| cookies | back to summary |
|---|---|
| public Set Returns a modifiable set of parsed cookies from the | |
| customFrameHandler | back to summary |
|---|---|
| public HttpServerRequest customFrameHandler(Handler<HttpFrame> handler) 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.
| |
| decoderResult | back to summary |
|---|---|
public DecoderResult decoderResult()
| |
| end | back to summary |
|---|---|
| public default void end(Handler<AsyncResult<Void>> handler) Same as | |
| end | back to summary |
|---|---|
| public Future Returns a future signaling when the request has been fully received successfully or failed. | |
| endHandler | back to summary |
|---|---|
public HttpServerRequest endHandler(Handler<Void> endHandler)
| |
| exceptionHandler | back to summary |
|---|---|
public HttpServerRequest exceptionHandler(Handler<Throwable> handler)
| |
| fetch | back to summary |
|---|---|
| public HttpServerRequest fetch(long amount) Redeclares io. Doc from io. Fetch the specified
| |
| formAttributes | back to summary |
|---|---|
| public 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.
| |
| getCookie | back to summary |
|---|---|
| public @Nullable Cookie getCookie(String name) Get the cookie with the specified name. Note this will return just the 1st | |
| getCookie | back to summary |
|---|---|
| public @Nullable Cookie getCookie(String name, String domain, String path) Get the cookie with the specified | |
| getFormAttribute | back to summary |
|---|---|
| public @Nullable String getFormAttribute(String attributeName) Return the first form attribute value with the specified name | |
| getHeader | back to summary |
|---|---|
| public default @Nullable String getHeader(String headerName) Return the first header value with the specified name | |
| getHeader | back to summary |
|---|---|
| public default String getHeader(CharSequence headerName) Return the first header value with the specified name
| |
| getParam | back to summary |
|---|---|
| public default @Nullable String getParam(String paramName) Return the first param value with the specified name | |
| getParam | back to summary |
|---|---|
| public default String getParam(String paramName, String defaultValue) Return the first param value with the specified name or | |
| getParamsCharset | back to summary |
|---|---|
public String getParamsCharset()
| |
| handler | back to summary |
|---|---|
public HttpServerRequest handler(Handler<Buffer> handler)
| |
| headers | back to summary |
|---|---|
public MultiMap headers()
| |
| host | back to summary |
|---|---|
| public @Nullable String host()
Deprecated instead use | |
| isEnded | back to summary |
|---|---|
| public boolean isEnded() Has the request ended? I.e. has the entire request, including the body been read?
| |
| isExpectMultipart | back to summary |
|---|---|
public boolean isExpectMultipart()
| |
| isSSL | back to summary |
|---|---|
public default boolean isSSL()
| |
| localAddress | back to summary |
|---|---|
public default SocketAddress localAddress()
| |
| method | back to summary |
|---|---|
public HttpMethod method()
| |
| params | back to summary |
|---|---|
public default MultiMap params()
| |
| params | back to summary |
|---|---|
public MultiMap params(boolean semicolonIsNormalChar)
| |
| path | back to summary |
|---|---|
| public @Nullable String path() | |
| pause | back to summary |
|---|---|
| public HttpServerRequest pause() Redeclares io. Doc from io. Pause the
While it's paused, no data will be sent to the data
| |
| peerCertificateChain | back to summary |
|---|---|
| public X509Certificate[] peerCertificateChain() throws SSLPeerUnverifiedException
References Deprecated
See corresponding docs for further information. Note Java SE 5+ recommends to use javax.net.ssl.SSLSession#getPeerCertificates() instead of
of javax.net.ssl.SSLSession#getPeerCertificateChain() which this method is based on. Use
| |
| query | back to summary |
|---|---|
| public @Nullable String query() | |
| remoteAddress | back to summary |
|---|---|
public default SocketAddress remoteAddress()
| |
| response | back to summary |
|---|---|
public HttpServerResponse response()
| |
| resume | back to summary |
|---|---|
| public HttpServerRequest resume() Redeclares io. Doc from io. Resume reading, and sets the buffer in
If the
| |
| routed | back to summary |
|---|---|
| public default HttpServerRequest routed(String route) Marks this request as being routed to the given route. This is purely informational and is being provided to metrics. | |
| scheme | back to summary |
|---|---|
| public @Nullable String scheme() | |
| setExpectMultipart | back to summary |
|---|---|
| public HttpServerRequest setExpectMultipart(boolean expect) 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
| |
| setParamsCharset | back to summary |
|---|---|
| public HttpServerRequest setParamsCharset(String charset) Override the charset to use for decoding the query parameter map, when none is set,
| |
| sslSession | back to summary |
|---|---|
public default SSLSession sslSession()
| |
| streamId | back to summary |
|---|---|
public default int streamId()
| |
| streamPriority | back to summary |
|---|---|
public default StreamPriority streamPriority()
| |
| streamPriorityHandler | back to summary |
|---|---|
| public HttpServerRequest streamPriorityHandler(Handler<StreamPriority> handler) Set an handler for stream priority changes This is not implemented for HTTP/1.x.
| |
| toNetSocket | back to summary |
|---|---|
| public default void toNetSocket(Handler<AsyncResult<NetSocket>> handler) Establish a TCP tunnel with the client. This must be called only for Calling this sends a
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);
});
}
...
});
| |
| toNetSocket | back to summary |
|---|---|
| public Future Like | |
| toWebSocket | back to summary |
|---|---|
| public default void toWebSocket(Handler<AsyncResult<ServerWebSocket>> handler) 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
Both If you need to do an asynchronous upgrade, i.e not performed immediately in your request handler,
you need to
| |
| toWebSocket | back to summary |
|---|---|
| public Future Like | |
| uploadHandler | back to summary |
|---|---|
| public HttpServerRequest uploadHandler(@Nullable Handler<HttpServerFileUpload> 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.
| |
| uri | back to summary |
|---|---|
public String uri()
| |
| version | back to summary |
|---|---|
public HttpVersion version()
| |