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 |
__construct()
absoluteURI() : string
string
the absolute URI corresponding to the the HTTP request
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.
callable
$this
bytesRead() : integer
integer
the total number of bytes read for the body of the request.
connection() : \io\vertx\jphp\core\http\HttpConnection
\io\vertx\jphp\core\http\HttpConnection
the {@link HttpConnection} associated with this request
customFrameHandler( $arg0) : $this
callable
$this
a reference to this, so the API can be used fluently
endHandler( $arg0) : $this
callable
$this
exceptionHandler( $arg0) : $this
callable
$this
fetch( $arg0) : $this
integer
$this
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. |
---|---|
\io\vertx\jphp\core\MultiMap
the form attributes
getFormAttribute( $arg0) : string
string
string
the attribute value
getHeader( $arg0) : string
string
string
the header value
getParam( $arg0) : string
string
string
the param value
handler( $arg0) : $this
callable
$this
headers() : \io\vertx\jphp\core\MultiMap
host() : string
string
the request host. For HTTP2 it returns the {@literal :authority} pseudo header otherwise it returns the {@literal Host} header
isEnded() : boolean
boolean
true if ended
isExpectMultipart() : boolean
boolean
true if we are expecting a multi-part body for this request. See {@link #setExpectMultipart}.
isSSL() : boolean
boolean
true if this {@link io.vertx.core.net.NetSocket} is encrypted via SSL/TLS
localAddress() : \io\vertx\jphp\core\net\SocketAddress
\io\vertx\jphp\core\net\SocketAddress
the local (server side) address of the server that handles the request
method() : string
string
the HTTP method for the 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.
\io\vertx\jphp\core\net\NetSocket
the net socket
params() : \io\vertx\jphp\core\MultiMap
path() : string
string
The path part of the uri. For example /somepath/somemorepath/someresource.foo
pause() : $this
$this
query() : string
string
the query part of the uri. For example someparam=32&someotherparam=x
rawMethod() : string
string
the HTTP method as sent by the client
remoteAddress() : \io\vertx\jphp\core\net\SocketAddress
response() : \io\vertx\jphp\core\http\HttpServerResponse
\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() : $this
$this
scheme() : string
string
the scheme of the request
setExpectMultipart( $arg0) : $this
This must be called before the body of the request has been received
boolean
$this
a reference to this, so the API can be used fluently
streamPriority() : \io\vertx\jphp\core\http\StreamPriority
\io\vertx\jphp\core\http\StreamPriority
the priority of the associated HTTP/2 stream for HTTP/2 otherwise {@code null}
streamPriorityHandler( $arg0) : $this
callable
$this
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.
\io\vertx\jphp\core\http\ServerWebSocket
the WebSocket
uploadHandler( $arg0) : $this
callable
$this
a reference to this, so the API can be used fluently
uri() : string
string
the URI of the request. This is usually a relative URI
version() : string
string
the HTTP version of the request