public interface HttpServerRequest extends ReadStream<Buffer>
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
Pump
to pump data with flow control.
Modifier and Type | Method and Description |
---|---|
String |
absoluteURI() |
default HttpServerRequest |
bodyHandler(Handler<Buffer> bodyHandler)
Convenience method for receiving the entire request body in one piece.
|
HttpConnection |
connection() |
HttpServerRequest |
customFrameHandler(Handler<HttpFrame> handler)
Set a custom frame handler.
|
HttpServerRequest |
endHandler(Handler<Void> endHandler)
Set an end handler.
|
HttpServerRequest |
exceptionHandler(Handler<Throwable> handler)
Set an exception handler on the read stream.
|
MultiMap |
formAttributes()
Returns a map of all form attributes in the request.
|
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
ReadSupport . |
X509Certificate[] |
peerCertificateChain() |
String |
query() |
String |
rawMethod() |
SocketAddress |
remoteAddress() |
HttpServerResponse |
response() |
HttpServerRequest |
resume()
Resume reading.
|
String |
scheme() |
HttpServerRequest |
setExpectMultipart(boolean expect)
Call this with true if you are expecting a multi-part body to be submitted in the request.
|
ServerWebSocket |
upgrade()
Upgrade the connection to a WebSocket connection.
|
HttpServerRequest |
uploadHandler(Handler<HttpServerFileUpload> uploadHandler)
Set an upload handler.
|
String |
uri() |
HttpVersion |
version() |
HttpServerRequest exceptionHandler(Handler<Throwable> handler)
ReadStream
exceptionHandler
in interface ReadStream<Buffer>
exceptionHandler
in interface StreamBase
handler
- the exception handlerHttpServerRequest handler(Handler<Buffer> handler)
ReadStream
handler
in interface ReadStream<Buffer>
HttpServerRequest pause()
ReadStream
ReadSupport
. While it's paused, no data will be sent to the dataHandler
pause
in interface ReadStream<Buffer>
HttpServerRequest resume()
ReadStream
ReadSupport
has been paused, reading will recommence on it.resume
in interface ReadStream<Buffer>
HttpServerRequest endHandler(Handler<Void> endHandler)
ReadStream
endHandler
in interface ReadStream<Buffer>
HttpVersion version()
HttpMethod method()
String rawMethod()
boolean isSSL()
NetSocket
is encrypted via SSL/TLSString scheme()
String uri()
String path()
String query()
String host()
HttpServerResponse response()
HttpServerResponse
instance attached to it. This is used
to send the response back to the client.MultiMap headers()
String getHeader(String headerName)
headerName
- the header nameString getHeader(CharSequence headerName)
headerName
- the header nameMultiMap params()
String getParam(String paramName)
paramName
- the param nameSocketAddress remoteAddress()
SocketAddress localAddress()
X509Certificate[] peerCertificateChain() throws SSLPeerUnverifiedException
SSLPeerUnverifiedException
- SSL peer's identity has not been verified.String absoluteURI()
default HttpServerRequest bodyHandler(Handler<Buffer> bodyHandler)
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.
bodyHandler
- This handler will be called after all the body has been receivedNetSocket netSocket()
USE THIS WITH CAUTION!
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. Writing to the socket directly if you don't know what you're doing can easily break the HTTP protocol.
HttpServerRequest setExpectMultipart(boolean expect)
expect
- true - if you are expecting a multi-part bodyboolean isExpectMultipart()
setExpectMultipart(boolean)
.HttpServerRequest uploadHandler(Handler<HttpServerFileUpload> uploadHandler)
MultiMap formAttributes()
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.
String getFormAttribute(String attributeName)
attributeName
- the attribute nameServerWebSocket upgrade()
This is an alternative way of handling WebSockets and can only be used if no websocket handlers are set on the Http server, and can only be used during the upgrade request during the WebSocket handshake.
boolean isEnded()
HttpServerRequest customFrameHandler(Handler<HttpFrame> handler)
HttpConnection connection()
HttpConnection
associated with this requestCopyright © 2016. All rights reserved.