public class HttpServerRequest extends Object implements 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.
NOTE: This class has been automatically generated from the
original
non RX-ified interface using Vert.x codegen.Constructor and Description |
---|
HttpServerRequest(HttpServerRequest delegate) |
Modifier and Type | Method and Description |
---|---|
String |
absoluteURI() |
HttpServerRequest |
bodyHandler(Handler<Buffer> bodyHandler)
Convenience method for receiving the entire request body in one piece.
|
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.
|
Object |
getDelegate() |
String |
getFormAttribute(String attributeName)
Return the first form attribute 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() |
boolean |
isEnded()
Has the request ended? I.e.
|
boolean |
isExpectMultipart() |
SocketAddress |
localAddress() |
HttpMethod |
method() |
NetSocket |
netSocket()
Get a net socket for the underlying connection of this request.
|
static HttpServerRequest |
newInstance(HttpServerRequest arg) |
MultiMap |
params() |
String |
path() |
HttpServerRequest |
pause()
Pause the
ReadSupport . |
String |
query() |
SocketAddress |
remoteAddress() |
HttpServerResponse |
response() |
HttpServerRequest |
resume()
Resume reading.
|
HttpServerRequest |
setExpectMultipart(boolean expect)
Call this with true if you are expecting a multi-part body to be submitted in the request.
|
rx.Observable<Buffer> |
toObservable() |
ServerWebSocket |
upgrade()
Upgrade the connection to a WebSocket connection.
|
HttpServerRequest |
uploadHandler(Handler<HttpServerFileUpload> uploadHandler)
Set an upload handler.
|
String |
uri() |
HttpVersion |
version() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
newInstance
newInstance
public HttpServerRequest(HttpServerRequest delegate)
public Object getDelegate()
getDelegate
in interface ReadStream<Buffer>
getDelegate
in interface StreamBase
public rx.Observable<Buffer> toObservable()
toObservable
in interface ReadStream<Buffer>
public HttpServerRequest exceptionHandler(Handler<Throwable> handler)
ReadStream
exceptionHandler
in interface ReadStream<Buffer>
exceptionHandler
in interface StreamBase
handler
- the exception handlerpublic HttpServerRequest handler(Handler<Buffer> handler)
ReadStream
handler
in interface ReadStream<Buffer>
public HttpServerRequest pause()
ReadStream
ReadSupport
. While it's paused, no data will be sent to the dataHandler
pause
in interface ReadStream<Buffer>
public HttpServerRequest resume()
ReadStream
ReadSupport
has been paused, reading will recommence on it.resume
in interface ReadStream<Buffer>
public HttpServerRequest endHandler(Handler<Void> endHandler)
ReadStream
endHandler
in interface ReadStream<Buffer>
public HttpVersion version()
public HttpMethod method()
public String uri()
public String path()
public String query()
public HttpServerResponse response()
HttpServerResponse
instance attached to it. This is used
to send the response back to the client.public MultiMap headers()
public String getHeader(String headerName)
headerName
- the header namepublic MultiMap params()
public String getParam(String paramName)
paramName
- the param namepublic SocketAddress remoteAddress()
public SocketAddress localAddress()
public String absoluteURI()
public 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 receivedpublic NetSocket 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.
public HttpServerRequest setExpectMultipart(boolean expect)
expect
- true - if you are expecting a multi-part bodypublic boolean isExpectMultipart()
setExpectMultipart(boolean)
.public HttpServerRequest uploadHandler(Handler<HttpServerFileUpload> uploadHandler)
uploadHandler
- public 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.
public String getFormAttribute(String attributeName)
attributeName
- the attribute namepublic ServerWebSocket 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.
public boolean isEnded()
public static HttpServerRequest newInstance(HttpServerRequest arg)
Copyright © 2015. All Rights Reserved.