class HttpServerRequest extends ReadStream[Buffer]
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 io.vertx.scala.core.http.HttpServerResponse instance via io.vertx.scala.core.http.HttpServerRequest#response. It implements io.vertx.scala.core.streams.ReadStream so it can be used with io.vertx.scala.core.streams.Pump to pump data with flow control.
- Alphabetic
- By Inheritance
- HttpServerRequest
- ReadStream
- StreamBase
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
- new HttpServerRequest(_asJava: AnyRef)
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
absoluteURI(): String
- returns
the absolute URI corresponding to the the HTTP request
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
asJava: AnyRef
- Definition Classes
- HttpServerRequest → ReadStream → StreamBase
-
def
bodyHandler(bodyHandler: Handler[Buffer]): HttpServerRequest
Convenience method for receiving the entire request body in one piece.
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. * @param bodyHandler This handler will be called after all the body has been received
-
def
bytesRead(): Long
- returns
the total number of bytes read for the body of the request.
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
def
connection(): HttpConnection
- returns
the HttpConnection associated with this request
-
def
customFrameHandler(handler: Handler[HttpFrame]): HttpServerRequest
Set a custom frame handler.
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. * @return a reference to this, so the API can be used fluently
-
def
endHandler(endHandler: Handler[Unit]): HttpServerRequest
Set an end handler.
Set an end handler. Once the stream has ended, and there is no more data to be read, this handler will be called. * @return a reference to this, so the API can be used fluently
- Definition Classes
- HttpServerRequest → ReadStream
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
exceptionHandler(handler: Handler[Throwable]): HttpServerRequest
Set an exception handler on the read stream.
Set an exception handler on the read stream. * @param handler the exception handler
- returns
a reference to this, so the API can be used fluently
- Definition Classes
- HttpServerRequest → ReadStream → StreamBase
-
def
fetch(amount: Long): HttpServerRequest
Fetch the specified
amount
of elements.Fetch the specified
amount
of elements. If theReadStream
has been paused, reading will recommence with the specifiedamount
of items, otherwise the specifiedamount
will be added to the current stream demand. * @return a reference to this, so the API can be used fluently- Definition Classes
- HttpServerRequest → ReadStream
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
formAttributes(): MultiMap
Returns a map of all form attributes in the request.
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.
io.vertx.scala.core.http.HttpServerRequest#setExpectMultipart must be called first before trying to get the form attributes. * @return the form attributes
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
getFormAttribute(attributeName: String): Option[String]
Return the first form attribute value with the specified name * @param attributeName the attribute name
Return the first form attribute value with the specified name * @param attributeName the attribute name
- returns
the attribute value
-
def
getHeader(headerName: String): Option[String]
Return the first header value with the specified name * @param headerName the header name
Return the first header value with the specified name * @param headerName the header name
- returns
the header value
-
def
getParam(paramName: String): Option[String]
Return the first param value with the specified name * @param paramName the param name
Return the first param value with the specified name * @param paramName the param name
- returns
the param value
-
def
handler(handler: Handler[Buffer]): HttpServerRequest
Set a data handler.
Set a data handler. As data is read, the handler will be called with the data. * @return a reference to this, so the API can be used fluently
- Definition Classes
- HttpServerRequest → ReadStream
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
headers(): MultiMap
- returns
the headers in the request.
-
def
host(): Option[String]
- returns
the request host. For HTTP2 it returns the
:authority
pseudo header otherwise it returns theHost
header
-
def
isEnded(): Boolean
Has the request ended? I.e.
Has the request ended? I.e. has the entire request, including the body been read? * @return true if ended
-
def
isExpectMultipart(): Boolean
- returns
true if we are expecting a multi-part body for this request. See #setExpectMultipart.
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
isSSL(): Boolean
- returns
true if this io.vertx.scala.core.net.NetSocket is encrypted via SSL/TLS
-
def
localAddress(): SocketAddress
- returns
the local (server side) address of the server that handles the request
-
def
method(): HttpMethod
- returns
the HTTP method for the request.
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
netSocket(): NetSocket
Get a net socket for the underlying connection of this request.
Get a net socket for the underlying connection of this request.
This method must be called before the server response is ended.
With
CONNECT
requests, a200
response is sent with nocontent-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 nocontent-length
header set before returning the socket like in theCONNECT
case above.- returns
the net socket
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
params(): MultiMap
- returns
the query parameters in the request
-
def
path(): Option[String]
- returns
The path part of the uri. For example /somepath/somemorepath/someresource.foo
-
def
pause(): HttpServerRequest
Pause the
ReadStream
, it sets the buffer infetch
mode and clears the actual demand.Pause the
ReadStream
, it sets the buffer infetch
mode and clears the actual demand.While it's paused, no data will be sent to the data
handler
. * @return a reference to this, so the API can be used fluently- Definition Classes
- HttpServerRequest → ReadStream
-
def
query(): Option[String]
- returns
the query part of the uri. For example someparam=32&someotherparam=x
-
def
rawMethod(): String
- returns
the HTTP method as sent by the client
-
def
remoteAddress(): SocketAddress
- returns
the remote (client side) address of the request
-
def
response(): HttpServerResponse
- returns
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.
-
def
resume(): HttpServerRequest
Resume reading, and sets the buffer in
flowing
mode.Resume reading, and sets the buffer in
flowing
mode.If the
ReadStream
has been paused, reading will recommence on it. * @return a reference to this, so the API can be used fluently- Definition Classes
- HttpServerRequest → ReadStream
-
def
scheme(): Option[String]
- returns
the scheme of the request
-
def
setExpectMultipart(expect: Boolean): HttpServerRequest
Call this with true if you are expecting a multi-part body to be submitted in the request.
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 * @param expect true - if you are expecting a multi-part body
- returns
a reference to this, so the API can be used fluently
-
def
streamPriority(): StreamPriority
- returns
the priority of the associated HTTP/2 stream for HTTP/2 otherwise
null
see StreamPriority
-
def
streamPriorityHandler(handler: Handler[StreamPriority]): HttpServerRequest
Set an handler for stream priority changes
Set an handler for stream priority changes
This is not implemented for HTTP/1.x. * @param handler the handler to be called when stream priority changes
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
def
upgrade(): ServerWebSocket
Upgrade the connection to a WebSocket connection.
Upgrade 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. * @return the WebSocket
-
def
uploadHandler(uploadHandler: Handler[HttpServerFileUpload]): HttpServerRequest
Set an upload handler.
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. * @return a reference to this, so the API can be used fluently
-
def
uri(): String
- returns
the URI of the request. This is usually a relative URI
-
def
version(): HttpVersion
- returns
the HTTP version of the request
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )