HttpServerRequest

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 @see \io\vertx\jphp\core\http\HttpServerResponse instance via

see

It implements @see \io\vertx\jphp\core\streams\ReadStream so it can be used with

see

to pump data with flow control.

package

Default

Methods

__construct

__construct() 

absoluteURI

absoluteURI() : string

Response

string

the absolute URI corresponding to the the HTTP request

Convenience method for receiving the entire request body in one piece.

bodyHandler( $arg0) : $this

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.

Arguments

$arg0

callable

Response

$this

bytesRead

bytesRead() : integer

Response

integer

the total number of bytes read for the body of the request.

connection

connection() : \io\vertx\jphp\core\http\HttpConnection

Response

\io\vertx\jphp\core\http\HttpConnection

the {@link HttpConnection} associated with this request

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.

customFrameHandler( $arg0) : $this

Arguments

$arg0

callable

Response

$this

a reference to this, so the API can be used fluently

endHandler

endHandler( $arg0) : $this

Arguments

$arg0

callable

Response

$this

exceptionHandler

exceptionHandler( $arg0) : $this

Arguments

$arg0

callable

Response

$this

fetch

fetch( $arg0) : $this

Arguments

$arg0

integer

Response

$this

Returns a map of all form attributes in the request.

formAttributes() : \io\vertx\jphp\core\MultiMap

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.

see \io\vertx\jphp\core\http\HttpServerRequest::setExpectMultipart

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

Response

\io\vertx\jphp\core\MultiMap

the form attributes

Return the first form attribute value with the specified name

getFormAttribute( $arg0) : string

Arguments

$arg0

string

Response

string

the attribute value

Return the first header value with the specified name

getHeader( $arg0) : string

Arguments

$arg0

string

Response

string

the header value

Return the first param value with the specified name

getParam( $arg0) : string

Arguments

$arg0

string

Response

string

the param value

handler

handler( $arg0) : $this

Arguments

$arg0

callable

Response

$this

headers

headers() : \io\vertx\jphp\core\MultiMap

Response

\io\vertx\jphp\core\MultiMap

the headers in the request.

host

host() : string

Response

string

the request host. For HTTP2 it returns the {@literal :authority} pseudo header otherwise it returns the {@literal Host} header

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

isEnded() : boolean

Response

boolean

true if ended

isExpectMultipart

isExpectMultipart() : boolean

Response

boolean

true if we are expecting a multi-part body for this request. See {@link #setExpectMultipart}.

isSSL

isSSL() : boolean

Response

boolean

true if this {@link io.vertx.core.net.NetSocket} is encrypted via SSL/TLS

localAddress

localAddress() : \io\vertx\jphp\core\net\SocketAddress

Response

\io\vertx\jphp\core\net\SocketAddress

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

method

method() : string

Response

string

the HTTP method for the request.

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

netSocket() : \io\vertx\jphp\core\net\NetSocket

This method must be called before the server response is ended.

With CONNECT requests, a 200 response is sent with no content-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 no content-length header set before returning the socket like in the CONNECT case above.

Response

\io\vertx\jphp\core\net\NetSocket

the net socket

params

params() : \io\vertx\jphp\core\MultiMap

Response

\io\vertx\jphp\core\MultiMap

the query parameters in the request

path

path() : string

Response

string

The path part of the uri. For example /somepath/somemorepath/someresource.foo

pause

pause() : $this

Response

$this

query

query() : string

Response

string

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

rawMethod

rawMethod() : string

Response

string

the HTTP method as sent by the client

remoteAddress

remoteAddress() : \io\vertx\jphp\core\net\SocketAddress

Response

\io\vertx\jphp\core\net\SocketAddress

the remote (client side) address of the request

response

response() : \io\vertx\jphp\core\http\HttpServerResponse

Response

\io\vertx\jphp\core\http\HttpServerResponse

the response. Each instance of this class has an {@link HttpServerResponse} instance attached to it. This is used to send the response back to the client.

resume

resume() : $this

Response

$this

scheme

scheme() : string

Response

string

the scheme of the request

Call this with true if you are expecting a multi-part body to be submitted in the request.

setExpectMultipart( $arg0) : $this

This must be called before the body of the request has been received

Arguments

$arg0

boolean

Response

$this

a reference to this, so the API can be used fluently

streamPriority

streamPriority() : \io\vertx\jphp\core\http\StreamPriority

Response

\io\vertx\jphp\core\http\StreamPriority

the priority of the associated HTTP/2 stream for HTTP/2 otherwise {@code null}

Set an handler for stream priority changes <p> This is not implemented for HTTP/1.x.

streamPriorityHandler( $arg0) : $this

Arguments

$arg0

callable

Response

$this

Upgrade the connection to a WebSocket connection.

upgrade() : \io\vertx\jphp\core\http\ServerWebSocket

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.

Response

\io\vertx\jphp\core\http\ServerWebSocket

the WebSocket

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.

uploadHandler( $arg0) : $this

Arguments

$arg0

callable

Response

$this

a reference to this, so the API can be used fluently

uri

uri() : string

Response

string

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

version

version() : string

Response

string

the HTTP version of the request