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 response.

It implements ReadStream so it can be used with Pump to pump data with flow control.

no subtypes hierarchy

HttpServerRequest(HttpServerRequest unknown)
Inherited Attributes
Attributes inherited from: Object
hash, string
absoluteURIshared default String absoluteURI()

@return the absolute URI corresponding to the the HTTP request

bodyHandlershared default HttpServerRequest bodyHandler(Anything(Buffer)? bodyHandler)

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

endHandlershared actual default HttpServerRequest endHandler(Anything()? endHandler)

Set an end handler. Once the stream has ended, and there is no more data to be read, this handler will be called.

exceptionHandlershared actual default HttpServerRequest exceptionHandler(Anything(Throwable)? handler)

Set an exception handler.

formAttributesshared default MultiMap formAttributes()

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.

setExpectMultipart must be called first before trying to get the form attributes.

getFormAttributeshared default String? getFormAttribute(String attributeName)

Return the first form attribute value with the specified name

  • attributeName

    the attribute name

getHeadershared default String? getHeader(String headerName)

Return the first header value with the specified name

  • headerName

    the header name

getParamshared default String? getParam(String paramName)

Return the first param value with the specified name

  • paramName

    the param name

handlershared actual default HttpServerRequest handler(Anything(Buffer)? handler)

Set a data handler. As data is read, the handler will be called with the data.

headersshared default MultiMap headers()

@return the headers in the request.

isEndedshared default Boolean isEnded()

Has the request ended? I.e. has the entire request, including the body been read?

isExpectMultipartshared default Boolean isExpectMultipart()

@return true if we are expecting a multi-part body for this request. See setExpectMultipart.

isSSLshared default Boolean isSSL()

@return true if this NetSocket is encrypted via SSL/TLS

localAddressshared default SocketAddress localAddress()

@return the local (server side) address of the server that handles the request

methodshared default HttpMethod method()

@return the HTTP method for the request.

netSocketshared default NetSocket netSocket()

Get a net socket for the underlying connection of this request.


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.

paramsshared default MultiMap params()

@return the query parameters in the request

pathshared default String path()

@return The path part of the uri. For example /somepath/somemorepath/

pauseshared actual default HttpServerRequest pause()

Pause the ReadSupport. While it's paused, no data will be sent to the dataHandler

queryshared default String? query()

@return the query part of the uri. For example someparam=32&someotherparam=x

remoteAddressshared default SocketAddress remoteAddress()

@return the remote (client side) address of the request

responseshared default HttpServerResponse response()

@return 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.

resumeshared actual default HttpServerRequest resume()

Resume reading. If the ReadSupport has been paused, reading will recommence on it.

setExpectMultipartshared default HttpServerRequest setExpectMultipart(Boolean expect)

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 body

upgradeshared default ServerWebSocket upgrade()

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.

uploadHandlershared default HttpServerRequest uploadHandler(Anything(HttpServerFileUpload)? uploadHandler)

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.

urishared default String uri()

@return the URI of the request. This is usually a relative URI

versionshared default HttpVersion version()

@return the HTTP version of the request

Inherited Methods
Methods inherited from: Object
Methods inherited from: ReadStream<T>
Methods inherited from: StreamBase