@groovy.transform.CompileStatic class HttpServerRequest extends java.lang.Object
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 HttpServerResponse instance via HttpServerRequest.response.
It implements ReadStream so it can be used with Pump to pump data with flow control.
Constructor and description |
---|
HttpServerRequest
(java.lang.Object delegate) |
Type | Name and description |
---|---|
java.lang.String |
absoluteURI() @return
|
HttpServerRequest |
bodyHandler(io.vertx.core.Handler<Buffer> bodyHandler) Convenience method for receiving the entire request body in one piece. |
HttpConnection |
connection() @return
|
HttpServerRequest |
customFrameHandler(io.vertx.core.Handler<HttpFrame> handler) Set a custom frame handler. |
HttpServerRequest |
endHandler(io.vertx.core.Handler<java.lang.Void> endHandler) |
HttpServerRequest |
exceptionHandler(io.vertx.core.Handler<java.lang.Throwable> handler) |
MultiMap |
formAttributes() Returns a map of all form attributes in the request. |
java.lang.Object |
getDelegate() |
java.lang.String |
getFormAttribute(java.lang.String attributeName) Return the first form attribute value with the specified name |
java.lang.String |
getHeader(java.lang.String headerName) Return the first header value with the specified name |
java.lang.String |
getParam(java.lang.String paramName) Return the first param value with the specified name |
HttpServerRequest |
handler(io.vertx.core.Handler<Buffer> handler) |
MultiMap |
headers()
|
java.lang.String |
host()
|
boolean |
isEnded() Has the request ended? |
boolean |
isExpectMultipart()
|
boolean |
isSSL() @return
|
SocketAddress |
localAddress() @return
|
io.vertx.core.http.HttpMethod |
method()
|
NetSocket |
netSocket() Get a net socket for the underlying connection of this request. |
MultiMap |
params() @return
|
java.lang.String |
path()
|
HttpServerRequest |
pause() |
java.lang.String |
query()
|
java.lang.String |
rawMethod() @return
|
SocketAddress |
remoteAddress() @return
|
HttpServerResponse |
response()
|
HttpServerRequest |
resume() |
java.lang.String |
scheme() @return
|
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(io.vertx.core.Handler<HttpServerFileUpload> uploadHandler) Set an upload handler. |
java.lang.String |
uri()
|
io.vertx.core.http.HttpVersion |
version() @return
|
Methods inherited from class | Name |
---|---|
class java.lang.Object |
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
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.
bodyHandler
- This handler will be called after all the body has been received
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.
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.
HttpServerRequest.setExpectMultipart must be called first before trying to get the form attributes.
Return the first form attribute value with the specified name
attributeName
- the attribute nameReturn the first header value with the specified name
headerName
- the header nameReturn the first param value with the specified name
paramName
- the param name
Has the request ended? I.e. has the entire request, including the body been read?
Get a net socket for the underlying connection of this request.
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.
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
expect
- true - if you are expecting a multi-part bodyUpgrade the connection to a WebSocket connection.
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.
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.