public class Http2ServerRequestImpl extends Object implements HttpServerRequest
| Modifier and Type | Field and Description |
|---|---|
protected C |
conn |
protected String |
contentEncoding |
protected ContextInternal |
context |
protected io.netty.channel.ChannelHandlerContext |
handlerContext |
protected io.netty.handler.codec.http2.Http2Headers |
headers |
protected String |
host |
protected HttpMethod |
method |
protected String |
rawMethod |
protected Http2ServerResponseImpl |
response |
protected io.netty.handler.codec.http2.Http2Stream |
stream |
protected String |
uri |
protected VertxInternal |
vertx |
| Constructor and Description |
|---|
Http2ServerRequestImpl(Http2ServerConnection conn,
io.netty.handler.codec.http2.Http2Stream stream,
HttpServerMetrics metrics,
String serverOrigin,
io.netty.handler.codec.http2.Http2Headers headers,
String contentEncoding,
boolean writable,
boolean streamEnded) |
| Modifier and Type | Method and Description |
|---|---|
String |
absoluteURI() |
long |
bytesRead() |
HttpConnection |
connection() |
int |
cookieCount() |
Map<String,Cookie> |
cookieMap() |
HttpServerRequest |
customFrameHandler(Handler<HttpFrame> handler)
Set a custom frame handler.
|
void |
doFetch(long amount) |
void |
doPause() |
HttpServerRequest |
endHandler(Handler<Void> handler)
Set an end handler.
|
HttpServerRequest |
exceptionHandler(Handler<Throwable> handler)
Set an exception handler on the read stream.
|
HttpServerRequest |
fetch(long amount)
Fetch the specified
amount of elements. |
MultiMap |
formAttributes()
Returns a map of all form attributes in the request.
|
Cookie |
getCookie(String name)
Get the cookie with the specified name.
|
String |
getFormAttribute(String attributeName)
Return the first form attribute value with the specified name
|
String |
getHeader(CharSequence headerName)
Return the first header value with the specified name
|
String |
getHeader(String headerName)
Return the first header value with the specified name
|
String |
getParam(String paramName)
Return the first param value with the specified name
|
HttpServerRequest |
handler(Handler<Buffer> handler)
Set a data handler.
|
MultiMap |
headers() |
String |
host() |
boolean |
isEnded()
Has the request ended? I.e.
|
boolean |
isExpectMultipart() |
boolean |
isSSL() |
SocketAddress |
localAddress() |
HttpMethod |
method() |
NetSocket |
netSocket()
Get a net socket for the underlying connection of this request.
|
MultiMap |
params() |
String |
path() |
HttpServerRequest |
pause()
Pause the
ReadStream, it sets the buffer in fetch mode and clears the actual demand. |
X509Certificate[] |
peerCertificateChain()
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.
|
String |
query() |
String |
rawMethod() |
SocketAddress |
remoteAddress() |
Http2ServerResponseImpl |
response() |
HttpServerRequest |
resume()
Resume reading, and sets the buffer in
flowing mode. |
String |
scheme() |
HttpServerRequest |
setExpectMultipart(boolean expect)
Call this with true if you are expecting a multi-part body to be submitted in the request.
|
SSLSession |
sslSession() |
StreamPriority |
streamPriority() |
HttpServerRequest |
streamPriorityHandler(Handler<StreamPriority> handler)
Set an handler for stream priority changes
|
ServerWebSocket |
upgrade()
Upgrade the connection to a WebSocket connection.
|
HttpServerRequest |
uploadHandler(Handler<HttpServerFileUpload> handler)
Set an upload handler.
|
String |
uri() |
HttpVersion |
version() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitbodyHandler, method, rawMethodpipe, pipeTo, pipeToprotected final io.netty.handler.codec.http2.Http2Headers headers
protected final String rawMethod
protected final HttpMethod method
protected final String uri
protected final String contentEncoding
protected final String host
protected final Http2ServerResponseImpl response
protected final C extends io.vertx.core.http.impl.Http2ConnectionBase conn
protected final VertxInternal vertx
protected final ContextInternal context
protected final io.netty.channel.ChannelHandlerContext handlerContext
protected final io.netty.handler.codec.http2.Http2Stream stream
public Http2ServerRequestImpl(Http2ServerConnection conn, io.netty.handler.codec.http2.Http2Stream stream, HttpServerMetrics metrics, String serverOrigin, io.netty.handler.codec.http2.Http2Headers headers, String contentEncoding, boolean writable, boolean streamEnded)
public HttpServerRequest exceptionHandler(Handler<Throwable> handler)
ReadStreamexceptionHandler in interface HttpServerRequestexceptionHandler in interface ReadStream<Buffer>exceptionHandler in interface StreamBasehandler - the exception handlerpublic HttpServerRequest handler(Handler<Buffer> handler)
ReadStreamhandler in interface HttpServerRequesthandler in interface ReadStream<Buffer>public HttpServerRequest pause()
ReadStreamReadStream, it sets the buffer in fetch mode and clears the actual demand.
While it's paused, no data will be sent to the data handler.
pause in interface HttpServerRequestpause in interface ReadStream<Buffer>public HttpServerRequest resume()
ReadStreamflowing mode.
If the ReadStream has been paused, reading will recommence on it.resume in interface HttpServerRequestresume in interface ReadStream<Buffer>public HttpServerRequest fetch(long amount)
ReadStreamamount of elements. If the ReadStream has been paused, reading will
recommence with the specified amount of items, otherwise the specified amount will
be added to the current stream demand.fetch in interface HttpServerRequestfetch in interface ReadStream<Buffer>public HttpServerRequest endHandler(Handler<Void> handler)
ReadStreamendHandler in interface HttpServerRequestendHandler in interface ReadStream<Buffer>public HttpVersion version()
version in interface HttpServerRequestpublic boolean isSSL()
isSSL in interface HttpServerRequestNetSocket is encrypted via SSL/TLSpublic String uri()
uri in interface HttpServerRequestpublic String path()
path in interface HttpServerRequestpublic String query()
query in interface HttpServerRequestpublic String scheme()
scheme in interface HttpServerRequestpublic String host()
host in interface HttpServerRequestpublic long bytesRead()
bytesRead in interface HttpServerRequestpublic Http2ServerResponseImpl response()
response in interface HttpServerRequestHttpServerResponse instance attached to it. This is used
to send the response back to the client.public MultiMap headers()
headers in interface HttpServerRequestpublic String getHeader(String headerName)
HttpServerRequestgetHeader in interface HttpServerRequestheaderName - the header namepublic String getHeader(CharSequence headerName)
HttpServerRequestgetHeader in interface HttpServerRequestheaderName - the header namepublic MultiMap params()
params in interface HttpServerRequestpublic String getParam(String paramName)
HttpServerRequestgetParam in interface HttpServerRequestparamName - the param namepublic SocketAddress remoteAddress()
remoteAddress in interface HttpServerRequestpublic SocketAddress localAddress()
localAddress in interface HttpServerRequestpublic SSLSession sslSession()
sslSession in interface HttpServerRequestSSLSessionpublic X509Certificate[] peerCertificateChain() throws SSLPeerUnverifiedException
HttpServerRequestHttpServerRequest.sslSession() to
access that method.peerCertificateChain in interface HttpServerRequestSSLPeerUnverifiedException - SSL peer's identity has not been verified.SSLSession.getPeerCertificateChain(),
HttpServerRequest.sslSession()public String absoluteURI()
absoluteURI in interface HttpServerRequestpublic NetSocket netSocket()
HttpServerRequestCONNECT requests, a 200 response is sent with no content-length header set
before returning the socket.
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);
});
}
...
});
For other HTTP/1 requests once you have called this method, you must handle writing to the connection yourself using
the net socket, the server request instance will no longer be usable as normal. USE THIS WITH CAUTION! Writing to the socket directly if you don't know what you're
doing can easily break the HTTP protocol.
With HTTP/2, a 200 response is always sent with no content-length header set before returning the socket
like in the CONNECT case above.
netSocket in interface HttpServerRequestpublic HttpServerRequest setExpectMultipart(boolean expect)
HttpServerRequestsetExpectMultipart in interface HttpServerRequestexpect - true - if you are expecting a multi-part bodypublic boolean isExpectMultipart()
isExpectMultipart in interface HttpServerRequestHttpServerRequest.setExpectMultipart(boolean).public HttpServerRequest uploadHandler(Handler<HttpServerFileUpload> handler)
HttpServerRequestuploadHandler in interface HttpServerRequestpublic MultiMap formAttributes()
HttpServerRequestBe 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.
HttpServerRequest.setExpectMultipart(boolean) must be called first before trying to get the form attributes.
formAttributes in interface HttpServerRequestpublic String getFormAttribute(String attributeName)
HttpServerRequestgetFormAttribute in interface HttpServerRequestattributeName - the attribute namepublic ServerWebSocket upgrade()
HttpServerRequest
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.
upgrade in interface HttpServerRequestpublic boolean isEnded()
HttpServerRequestisEnded in interface HttpServerRequestpublic HttpServerRequest customFrameHandler(Handler<HttpFrame> handler)
HttpServerRequestcustomFrameHandler in interface HttpServerRequestpublic HttpConnection connection()
connection in interface HttpServerRequestHttpConnection associated with this requestpublic HttpServerRequest streamPriorityHandler(Handler<StreamPriority> handler)
HttpServerRequestThis is not implemented for HTTP/1.x.
streamPriorityHandler in interface HttpServerRequesthandler - the handler to be called when stream priority changespublic StreamPriority streamPriority()
streamPriority in interface HttpServerRequestnullpublic Cookie getCookie(String name)
HttpServerRequestgetCookie in interface HttpServerRequestname - the cookie namepublic int cookieCount()
cookieCount in interface HttpServerRequestpublic Map<String,Cookie> cookieMap()
cookieMap in interface HttpServerRequestpublic HttpMethod method()
public String rawMethod()
public void doPause()
public void doFetch(long amount)
Copyright © 2020. All rights reserved.