public interface HttpServerRequest extends ReadStream<Buffer>
Represents a server-side HTTP request.<p>
Instances are created for each request that is handled by the server
and is passed to the user via the Handler
instance
registered with the HttpServer
using the request stream HttpServer.requestStream()
.<p>
Each instance of this class is associated with a corresponding HttpServerResponse
instance via
the response
field.<p>
It implements ReadStream
so it can be used with
Pump
to pump data with flow control.<p>
Instances of this class are not thread-safe<p>
Modifier and Type | Method and Description |
---|---|
String |
absoluteURI()
Get the absolute URI corresponding to the the HTTP request
|
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.
|
MultiMap |
formAttributes()
Returns a map of all form attributes which was found in the request.
|
HttpServerRequest |
handler(Handler<Buffer> handler)
Set a data handler.
|
MultiMap |
headers()
A map of all headers in the request, If the request contains multiple headers with the same key, the values
will be concatenated together into a single header with the same key value, with each value separated by a comma,
as specified <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2">here</a>.
|
boolean |
isExpectMultipart() |
SocketAddress |
localAddress()
Return the local (server side) address of the server that handles the request
|
HttpMethod |
method()
The HTTP method for the request.
|
NetSocket |
netSocket()
Get a net socket for the underlying connection of this request.
|
MultiMap |
params()
Returns a map of all the parameters in the request
|
String |
path()
The path part of the uri.
|
HttpServerRequest |
pause()
Pause the
ReadSupport . |
X509Certificate[] |
peerCertificateChain() |
String |
query()
The query part of the uri.
|
SocketAddress |
remoteAddress()
Return the remote (client side) address of the request
|
HttpServerResponse |
response()
The response.
|
HttpServerRequest |
resume()
Resume reading.
|
HttpServerRequest |
setExpectMultipart(boolean expect)
Call this with true if you are expecting a multi-part form to be submitted in the request
This must be called before the body of the request has been received
|
HttpServerRequest |
uploadHandler(Handler<HttpServerFileUpload> uploadHandler)
Set the upload handler.
|
String |
uri()
The uri of the request.
|
HttpVersion |
version()
The HTTP version of the request
|
HttpServerRequest exceptionHandler(Handler<Throwable> handler)
StreamBase
Set an exception handler.
exceptionHandler
in interface ReadStream<Buffer>
exceptionHandler
in interface StreamBase
HttpServerRequest handler(Handler<Buffer> handler)
ReadStream
Set a data handler. As data is read, the handler will be called with the data.
handler
in interface ReadStream<Buffer>
HttpServerRequest pause()
ReadStream
Pause the ReadSupport
. While it’s paused, no data will be sent to the dataHandler
pause
in interface ReadStream<Buffer>
HttpServerRequest resume()
ReadStream
Resume reading. If the ReadSupport
has been paused, reading will recommence on it.
resume
in interface ReadStream<Buffer>
HttpServerRequest endHandler(Handler<Void> endHandler)
ReadStream
Set an end handler. Once the stream has ended, and there is no more data to be read, this handler will be called.
endHandler
in interface ReadStream<Buffer>
HttpVersion version()
The HTTP version of the request
HttpMethod method()
The HTTP method for the request. One of GET, PUT, POST, DELETE, TRACE, CONNECT, OPTIONS or HEAD
String uri()
The uri of the request. For example http://www.somedomain.com/somepath/somemorepath/someresource.foo?someparam=32&someotherparam=x
String path()
The path part of the uri. For example /somepath/somemorepath/someresource.foo
String query()
The query part of the uri. For example someparam=32&someotherparam=x
HttpServerResponse response()
The response. Each instance of this class has an HttpServerResponse
instance attached to it. This is used
to send the response back to the client.
MultiMap headers()
A map of all headers in the request, If the request contains multiple headers with the same key, the values will be concatenated together into a single header with the same key value, with each value separated by a comma, as specified <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2">here</a>. The headers will be automatically lower-cased when they reach the server
MultiMap params()
Returns a map of all the parameters in the request
SocketAddress remoteAddress()
Return the remote (client side) address of the request
SocketAddress localAddress()
Return the local (server side) address of the server that handles the request
X509Certificate[] peerCertificateChain() throws SSLPeerUnverifiedException
SSLPeerUnverifiedException
- SSL peer’s identity has not been verified.String absoluteURI()
Get the absolute URI corresponding to the the HTTP request
HttpServerRequest bodyHandler(Handler<Buffer> bodyHandler)
Convenience method for receiving the entire request body in one piece. This saves the user having to manually set 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()
Get a net socket for the underlying connection of this request. USE THIS WITH CAUTION! Writing to the socket directly if you don’t know what you’re doing can easily break the HTTP protocol
HttpServerRequest setExpectMultipart(boolean expect)
Call this with true if you are expecting a multi-part form to be submitted in the request This must be called before the body of the request has been received
expect
- boolean isExpectMultipart()
HttpServerRequest uploadHandler(Handler<HttpServerFileUpload> uploadHandler)
Set the upload handler. The handler will get notified once a new file upload was received and so allow to get notified by the upload in progress.
MultiMap formAttributes()
Returns a map of all form attributes which was found in the request. Be aware that this message should only get
called after the endHandler was notified as the map will be filled on-the-fly.
setExpectMultipart(boolean)
must be called first before trying to get the formAttributes
Copyright © 2014. All Rights Reserved.