Class: HttpServerRequest

vertx-js/http_server_request~ HttpServerRequest

new HttpServerRequest()

Represents a server-side HTTP request.

Instances are created for each request and passed to the user via a handler.

Source:

Methods

absoluteURI() → {string}

Source:
Returns:
the absolute URI corresponding to the the HTTP request
Type
string

bodyHandler(bodyHandler) → {HttpServerRequest}

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.

Parameters:
Name Type Description
bodyHandler function This handler will be called after all the body has been received
Source:
Returns:
Type
HttpServerRequest

connection() → {HttpConnection}

Source:
Returns:
the HttpConnection associated with this request
Type
HttpConnection

customFrameHandler(handler) → {HttpServerRequest}

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.
Parameters:
Name Type Description
handler function
Source:
Returns:
a reference to this, so the API can be used fluently
Type
HttpServerRequest

endHandler(endHandler) → {HttpServerRequest}

Parameters:
Name Type Description
endHandler function
Source:
Returns:
Type
HttpServerRequest

exceptionHandler(handler) → {HttpServerRequest}

Parameters:
Name Type Description
handler function
Source:
Returns:
Type
HttpServerRequest

formAttributes() → {MultiMap}

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.

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

Source:
Returns:
the form attributes
Type
MultiMap

getFormAttribute(attributeName) → {string}

Return the first form attribute value with the specified name
Parameters:
Name Type Description
attributeName string the attribute name
Source:
Returns:
the attribute value
Type
string

getHeader(headerName) → {string}

Return the first header value with the specified name
Parameters:
Name Type Description
headerName string the header name
Source:
Returns:
the header value
Type
string

getParam(paramName) → {string}

Return the first param value with the specified name
Parameters:
Name Type Description
paramName string the param name
Source:
Returns:
the param value
Type
string

handler(handler) → {HttpServerRequest}

Parameters:
Name Type Description
handler function
Source:
Returns:
Type
HttpServerRequest

headers() → {MultiMap}

Source:
Returns:
the headers in the request.
Type
MultiMap

host() → {string}

Source:
Returns:
the request host. For HTTP2 it returns the pseudo header otherwise it returns the header
Type
string

isEnded() → {boolean}

Has the request ended? I.e. has the entire request, including the body been read?
Source:
Returns:
true if ended
Type
boolean

isExpectMultipart() → {boolean}

Source:
Returns:
true if we are expecting a multi-part body for this request. See HttpServerRequest#setExpectMultipart.
Type
boolean

isSSL() → {boolean}

Source:
Returns:
true if this NetSocket is encrypted via SSL/TLS
Type
boolean

localAddress() → {SocketAddress}

Source:
Returns:
the local (server side) address of the server that handles the request
Type
SocketAddress

method() → {Object}

Source:
Returns:
the HTTP method for the request.
Type
Object

netSocket() → {NetSocket}

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

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.

Source:
Returns:
the net socket
Type
NetSocket

params() → {MultiMap}

Source:
Returns:
the query parameters in the request
Type
MultiMap

path() → {string}

Source:
Returns:
The path part of the uri. For example /somepath/somemorepath/someresource.foo
Type
string

pause() → {HttpServerRequest}

Source:
Returns:
Type
HttpServerRequest

query() → {string}

Source:
Returns:
the query part of the uri. For example someparam=32&someotherparam=x
Type
string

rawMethod() → {string}

Source:
Returns:
the HTTP method as sent by the client
Type
string

remoteAddress() → {SocketAddress}

Source:
Returns:
the remote (client side) address of the request
Type
SocketAddress

response() → {HttpServerResponse}

Source:
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.
Type
HttpServerResponse

resume() → {HttpServerRequest}

Source:
Returns:
Type
HttpServerRequest

scheme() → {string}

Source:
Returns:
the scheme of the request
Type
string

setExpectMultipart(expect) → {HttpServerRequest}

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
Parameters:
Name Type Description
expect boolean true - if you are expecting a multi-part body
Source:
Returns:
a reference to this, so the API can be used fluently
Type
HttpServerRequest

upgrade() → {ServerWebSocket}

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.

Source:
Returns:
the WebSocket
Type
ServerWebSocket

uploadHandler(uploadHandler) → {HttpServerRequest}

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.
Parameters:
Name Type Description
uploadHandler function
Source:
Returns:
a reference to this, so the API can be used fluently
Type
HttpServerRequest

uri() → {string}

Source:
Returns:
the URI of the request. This is usually a relative URI
Type
string

version() → {Object}

Source:
Returns:
the HTTP version of the request
Type
Object