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()
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

connectionshared default HttpConnection connection()
customFrameHandlershared default HttpServerRequest customFrameHandler(Anything(HttpFrame) 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.

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()
hostshared default String? host()
isEndedshared default Boolean isEnded()

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

isExpectMultipartshared default Boolean isExpectMultipart()
isSSLshared default Boolean isSSL()
localAddressshared default SocketAddress localAddress()
methodshared default HttpMethod method()
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()
pathshared default String? path()
pauseshared actual default HttpServerRequest pause()

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

queryshared default String? query()
rawMethodshared default String rawMethod()
remoteAddressshared default SocketAddress remoteAddress()
responseshared default HttpServerResponse response()
resumeshared actual default HttpServerRequest resume()

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

schemeshared default String? scheme()
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()
versionshared default HttpVersion version()
Inherited Methods
Methods inherited from: Object
Methods inherited from: ReadStream<T>
Methods inherited from: StreamBase