An asynchronous HTTP client.
It allows you to make requests to HTTP servers, and a single client can make requests to any server.
It also allows you to open WebSockets to servers.
The client can also pool HTTP connections.
For pooling to occur, keep-alive must be true on the @see \io\vertx\jphp\core\http\HttpClientOptions (default is true). In this case connections will be pooled and re-used if there are pending HTTP requests waiting to get a connection, otherwise they will be closed.
This gives the benefits of keep alive when the client is loaded but means we don't keep connections hanging around unnecessarily when there would be no benefits anyway.
The client also supports pipe-lining of requests. Pipe-lining means another request is sent on the same connection before the response from the preceding one has returned. Pipe-lining is not appropriate for all requests.
To enable pipe-lining, it must be enabled on the @see \io\vertx\jphp\core\http\HttpClientOptions (default is false).
When pipe-lining is enabled the connection will be automatically closed when all in-flight responses have returned and there are no outstanding pending requests to write.
The client is designed to be reused between requests.
package |
Default |
---|
__construct()
close() : void
Clients should always be closed after use.
connectionHandler( $arg0) : $this
callable
$this
a reference to this, so the API can be used fluently
delete( $arg0, $arg1 = null, $arg2 = null, $arg3 = null) : \io\vertx\jphp\core\http\HttpClientRequest
param $options [array] the request options delete($options)
Create an HTTP DELETE request to send to the server at the default host and port.
param $requestURI [string] the relative URI delete($requestURI)
Create an HTTP DELETE request to send to the server at the specified host and default port.
param $host [string] the host param $requestURI [string] the relative URI delete($host, $requestURI)
Create an HTTP DELETE request to send to the server with the specified options, specifying a response handler to receive the response
param $options [array] the request options param $responseHandler [callable] the response handler delete($options, $responseHandler)
Create an HTTP DELETE request to send to the server at the default host and port, specifying a response handler to receive the response
param $requestURI [string] the relative URI param $responseHandler [callable] the response handler delete($requestURI, $responseHandler)
Create an HTTP DELETE request to send to the server at the specified host and port.
param $port [integer] the port param $host [string] the host param $requestURI [string] the relative URI delete($port, $host, $requestURI)
Create an HTTP DELETE request to send to the server at the specified host and default port, specifying a response handler to receive the response
param $host [string] the host param $requestURI [string] the relative URI param $responseHandler [callable] the response handler delete($host, $requestURI, $responseHandler)
Create an HTTP DELETE request to send to the server at the specified host and port, specifying a response handler to receive the response
param $port [integer] the port param $host [string] the host param $requestURI [string] the relative URI param $responseHandler [callable] the response handler delete($port, $host, $requestURI, $responseHandler)
string | array | integer
callable | string
callable | string
callable
\io\vertx\jphp\core\http\HttpClientRequest
an HTTP client request object
deleteAbs( $arg0, $arg1 = null) : \io\vertx\jphp\core\http\HttpClientRequest
param $absoluteURI [string] the absolute URI deleteAbs($absoluteURI)
Create an HTTP DELETE request to send to the server using an absolute URI, specifying a response handler to receive the response
param $absoluteURI [string] the absolute URI param $responseHandler [callable] the response handler deleteAbs($absoluteURI, $responseHandler)
string
callable
\io\vertx\jphp\core\http\HttpClientRequest
an HTTP client request object
get( $arg0, $arg1 = null, $arg2 = null, $arg3 = null) : \io\vertx\jphp\core\http\HttpClientRequest
param $options [array] the request options get($options)
Create an HTTP GET request to send to the server at the default host and port.
param $requestURI [string] the relative URI get($requestURI)
Create an HTTP GET request to send to the server at the specified host and default port.
param $host [string] the host param $requestURI [string] the relative URI get($host, $requestURI)
Create an HTTP GET request to send to the server with the specified options, specifying a response handler to receive the response
param $options [array] the request options param $responseHandler [callable] the response handler get($options, $responseHandler)
Create an HTTP GET request to send to the server at the default host and port, specifying a response handler to receive the response
param $requestURI [string] the relative URI param $responseHandler [callable] the response handler get($requestURI, $responseHandler)
Create an HTTP GET request to send to the server at the specified host and port.
param $port [integer] the port param $host [string] the host param $requestURI [string] the relative URI get($port, $host, $requestURI)
Create an HTTP GET request to send to the server at the specified host and default port, specifying a response handler to receive the response
param $host [string] the host param $requestURI [string] the relative URI param $responseHandler [callable] the response handler get($host, $requestURI, $responseHandler)
Create an HTTP GET request to send to the server at the specified host and port, specifying a response handler to receive the response
param $port [integer] the port param $host [string] the host param $requestURI [string] the relative URI param $responseHandler [callable] the response handler get($port, $host, $requestURI, $responseHandler)
string | array | integer
callable | string
callable | string
callable
\io\vertx\jphp\core\http\HttpClientRequest
an HTTP client request object
getAbs( $arg0, $arg1 = null) : \io\vertx\jphp\core\http\HttpClientRequest
param $absoluteURI [string] the absolute URI getAbs($absoluteURI)
Create an HTTP GET request to send to the server using an absolute URI, specifying a response handler to receive the response
param $absoluteURI [string] the absolute URI param $responseHandler [callable] the response handler getAbs($absoluteURI, $responseHandler)
string
callable
\io\vertx\jphp\core\http\HttpClientRequest
an HTTP client request object
getNow( $arg0, $arg1, $arg2 = null, $arg3 = null) : $this
param $options [array] the request options param $responseHandler [callable] the response handler getNow($options, $responseHandler)
Sends an HTTP GET request to the server at the default host and port, specifying a response handler to receive the response
param $requestURI [string] the relative URI param $responseHandler [callable] the response handler getNow($requestURI, $responseHandler)
Sends an HTTP GET request to the server at the specified host and default port, specifying a response handler to receive the response
param $host [string] the host param $requestURI [string] the relative URI param $responseHandler [callable] the response handler getNow($host, $requestURI, $responseHandler)
Sends an HTTP GET request to the server at the specified host and port, specifying a response handler to receive the response
param $port [integer] the port param $host [string] the host param $requestURI [string] the relative URI param $responseHandler [callable] the response handler getNow($port, $host, $requestURI, $responseHandler)
string | array | integer
callable | string
callable | string
callable
$this
a reference to this, so the API can be used fluently
head( $arg0, $arg1 = null, $arg2 = null, $arg3 = null) : \io\vertx\jphp\core\http\HttpClientRequest
param $options [array] the request options head($options)
Create an HTTP HEAD request to send to the server at the default host and port.
param $requestURI [string] the relative URI head($requestURI)
Create an HTTP HEAD request to send to the server at the specified host and default port.
param $host [string] the host param $requestURI [string] the relative URI head($host, $requestURI)
Create an HTTP HEAD request to send to the server with the specified options, specifying a response handler to receive the response
param $options [array] the request options param $responseHandler [callable] the response handler head($options, $responseHandler)
Create an HTTP HEAD request to send to the server at the default host and port, specifying a response handler to receive the response
param $requestURI [string] the relative URI param $responseHandler [callable] the response handler head($requestURI, $responseHandler)
Create an HTTP HEAD request to send to the server at the specified host and port.
param $port [integer] the port param $host [string] the host param $requestURI [string] the relative URI head($port, $host, $requestURI)
Create an HTTP HEAD request to send to the server at the specified host and default port, specifying a response handler to receive the response
param $host [string] the host param $requestURI [string] the relative URI param $responseHandler [callable] the response handler head($host, $requestURI, $responseHandler)
Create an HTTP HEAD request to send to the server at the specified host and port, specifying a response handler to receive the response
param $port [integer] the port param $host [string] the host param $requestURI [string] the relative URI param $responseHandler [callable] the response handler head($port, $host, $requestURI, $responseHandler)
string | array | integer
callable | string
callable | string
callable
\io\vertx\jphp\core\http\HttpClientRequest
an HTTP client request object
headAbs( $arg0, $arg1 = null) : \io\vertx\jphp\core\http\HttpClientRequest
param $absoluteURI [string] the absolute URI headAbs($absoluteURI)
Create an HTTP HEAD request to send to the server using an absolute URI, specifying a response handler to receive the response
param $absoluteURI [string] the absolute URI param $responseHandler [callable] the response handler headAbs($absoluteURI, $responseHandler)
string
callable
\io\vertx\jphp\core\http\HttpClientRequest
an HTTP client request object
headNow( $arg0, $arg1, $arg2 = null, $arg3 = null) : $this
param $options [array] the request options param $responseHandler [callable] the response handler headNow($options, $responseHandler)
Sends an HTTP HEAD request to the server at the default host and port, specifying a response handler to receive the response
param $requestURI [string] the relative URI param $responseHandler [callable] the response handler headNow($requestURI, $responseHandler)
Sends an HTTP HEAD request to the server at the specified host and default port, specifying a response handler to receive the response
param $host [string] the host param $requestURI [string] the relative URI param $responseHandler [callable] the response handler headNow($host, $requestURI, $responseHandler)
Sends an HTTP HEAD request to the server at the specified host and port, specifying a response handler to receive the response
param $port [integer] the port param $host [string] the host param $requestURI [string] the relative URI param $responseHandler [callable] the response handler headNow($port, $host, $requestURI, $responseHandler)
string | array | integer
callable | string
callable | string
callable
$this
a reference to this, so the API can be used fluently
isMetricsEnabled() : boolean
boolean
{@code true} if metrics are enabled
post( $arg0, $arg1 = null, $arg2 = null, $arg3 = null) : \io\vertx\jphp\core\http\HttpClientRequest
param $options [array] the request options post($options)
Create an HTTP POST request to send to the server at the default host and port.
param $requestURI [string] the relative URI post($requestURI)
Create an HTTP POST request to send to the server at the specified host and default port.
param $host [string] the host param $requestURI [string] the relative URI post($host, $requestURI)
Create an HTTP POST request to send to the server with the specified options, specifying a response handler to receive the response
param $options [array] the request options param $responseHandler [callable] the response handler post($options, $responseHandler)
Create an HTTP POST request to send to the server at the default host and port, specifying a response handler to receive the response
param $requestURI [string] the relative URI param $responseHandler [callable] the response handler post($requestURI, $responseHandler)
Create an HTTP POST request to send to the server at the specified host and port.
param $port [integer] the port param $host [string] the host param $requestURI [string] the relative URI post($port, $host, $requestURI)
Create an HTTP POST request to send to the server at the specified host and default port, specifying a response handler to receive the response
param $host [string] the host param $requestURI [string] the relative URI param $responseHandler [callable] the response handler post($host, $requestURI, $responseHandler)
Create an HTTP POST request to send to the server at the specified host and port, specifying a response handler to receive the response
param $port [integer] the port param $host [string] the host param $requestURI [string] the relative URI param $responseHandler [callable] the response handler post($port, $host, $requestURI, $responseHandler)
string | array | integer
callable | string
callable | string
callable
\io\vertx\jphp\core\http\HttpClientRequest
an HTTP client request object
postAbs( $arg0, $arg1 = null) : \io\vertx\jphp\core\http\HttpClientRequest
param $absoluteURI [string] the absolute URI postAbs($absoluteURI)
Create an HTTP POST request to send to the server using an absolute URI, specifying a response handler to receive the response
param $absoluteURI [string] the absolute URI param $responseHandler [callable] the response handler postAbs($absoluteURI, $responseHandler)
string
callable
\io\vertx\jphp\core\http\HttpClientRequest
an HTTP client request object
put( $arg0, $arg1 = null, $arg2 = null, $arg3 = null) : \io\vertx\jphp\core\http\HttpClientRequest
param $options [array] the request options put($options)
Create an HTTP PUT request to send to the server at the default host and port.
param $requestURI [string] the relative URI put($requestURI)
Create an HTTP PUT request to send to the server at the specified host and default port.
param $host [string] the host param $requestURI [string] the relative URI put($host, $requestURI)
Create an HTTP PUT request to send to the server with the specified options, specifying a response handler to receive the response
param $options [array] the request options param $responseHandler [callable] the response handler put($options, $responseHandler)
Create an HTTP PUT request to send to the server at the default host and port, specifying a response handler to receive the response
param $requestURI [string] the relative URI param $responseHandler [callable] the response handler put($requestURI, $responseHandler)
Create an HTTP PUT request to send to the server at the specified host and port.
param $port [integer] the port param $host [string] the host param $requestURI [string] the relative URI put($port, $host, $requestURI)
Create an HTTP PUT request to send to the server at the specified host and default port, specifying a response handler to receive the response
param $host [string] the host param $requestURI [string] the relative URI param $responseHandler [callable] the response handler put($host, $requestURI, $responseHandler)
Create an HTTP PUT request to send to the server at the specified host and port, specifying a response handler to receive the response
param $port [integer] the port param $host [string] the host param $requestURI [string] the relative URI param $responseHandler [callable] the response handler put($port, $host, $requestURI, $responseHandler)
string | array | integer
callable | string
callable | string
callable
\io\vertx\jphp\core\http\HttpClientRequest
an HTTP client request object
putAbs( $arg0, $arg1 = null) : \io\vertx\jphp\core\http\HttpClientRequest
param $absoluteURI [string] the absolute URI putAbs($absoluteURI)
Create an HTTP PUT request to send to the server using an absolute URI, specifying a response handler to receive the response
param $absoluteURI [string] the absolute URI param $responseHandler [callable] the response handler putAbs($absoluteURI, $responseHandler)
string
callable
\io\vertx\jphp\core\http\HttpClientRequest
an HTTP client request object
redirectHandler( $arg0) : $this
The redirect handler is called when a 3xx
response is received and the request is configured to
follow redirects with @see \io\vertx\jphp\core\http\HttpClientRequest::setFollowRedirects.
The redirect handler is passed the @see \io\vertx\jphp\core\http\HttpClientResponse, it can return an @see \io\vertx\jphp\core\http\HttpClientRequest or null
.
Future
is returned, the client will send this new request
The handler must return a Future
unsent so the client can further configure it and send it.
callable
$this
a reference to this, so the API can be used fluently
request( $arg0, $arg1, $arg2 = null, $arg3 = null, $arg4 = null, $arg5 = null) : \io\vertx\jphp\core\http\HttpClientRequest
param $method [string] the HTTP method param $options [array] the request options request($method, $options)
Create an HTTP request to send to the server at the default host and port.
param $method [string] the HTTP method param $requestURI [string] the relative URI request($method, $requestURI)
Like @see \io\vertx\jphp\core\http\HttpClient::request using the serverAddress
parameter to connect to the
server instead of the absoluteURI
parameter.
The request host header will still be created from the options
parameter.
Use to connect to a unix domain socket server.
param $method [string]
param $serverAddress [SocketAddress]
param $options [array]
request($method, $serverAddress, $options)
Create an HTTP request to send to the server at the specified host and default port.
param $method [string] the HTTP method
param $host [string] the host
param $requestURI [string] the relative URI
request($method, $host, $requestURI)
Create an HTTP request to send to the server with the specified options, specifying a response handler to receive
param $method [string] the HTTP method
param $options [array] the request options
param $responseHandler [callable]
request($method, $options, $responseHandler)
Create an HTTP request to send to the server at the default host and port, specifying a response handler to receive
the response
param $method [string] the HTTP method
param $requestURI [string] the relative URI
param $responseHandler [callable] the response handler
request($method, $requestURI, $responseHandler)
Create an HTTP request to send to the server at the specified host and port.
param $method [string] the HTTP method
param $port [integer] the port
param $host [string] the host
param $requestURI [string] the relative URI
request($method, $port, $host, $requestURI)
Like @see \io\vertx\jphp\core\http\HttpClient::request using the serverAddress
parameter to connect to the
server instead of the absoluteURI
parameter.
The request host header will still be created from the options
parameter.
Use to connect to a unix domain socket server.
param $method [string]
param $serverAddress [SocketAddress]
param $options [array]
param $responseHandler [callable]
request($method, $serverAddress, $options, $responseHandler)
Create an HTTP request to send to the server at the specified host and default port, specifying a response handler to receive
the response
param $method [string] the HTTP method
param $host [string] the host
param $requestURI [string] the relative URI
param $responseHandler [callable] the response handler
request($method, $host, $requestURI, $responseHandler)
Like @see \io\vertx\jphp\core\http\HttpClient::request using the serverAddress
parameter to connect to the
server instead of the absoluteURI
parameter.
The request host header will still be created from the host
and port
parameters.
Use to connect to a unix domain socket server.
param $method [string]
param $serverAddress [SocketAddress]
param $port [integer]
param $host [string]
param $requestURI [string]
request($method, $serverAddress, $port, $host, $requestURI)
Create an HTTP request to send to the server at the specified host and port, specifying a response handler to receive
the response
param $method [string] the HTTP method
param $port [integer] the port
param $host [string] the host
param $requestURI [string] the relative URI
param $responseHandler [callable] the response handler
request($method, $port, $host, $requestURI, $responseHandler)
Like @see \io\vertx\jphp\core\http\HttpClient::request using the serverAddress
parameter to connect to the
server instead of the absoluteURI
parameter.
The request host header will still be created from the host
and port
parameters.
Use to connect to a unix domain socket server. param $method [string] param $serverAddress [SocketAddress] param $port [integer] param $host [string] param $requestURI [string] param $responseHandler [callable] request($method, $serverAddress, $port, $host, $requestURI, $responseHandler)
string
string | array | integer | SocketAddress
callable | string | array | integer
callable | string
callable | string
callable
\io\vertx\jphp\core\http\HttpClientRequest
an HTTP client request object
requestAbs( $arg0, $arg1, $arg2 = null, $arg3 = null) : \io\vertx\jphp\core\http\HttpClientRequest
param $method [string] the HTTP method param $absoluteURI [string] the absolute URI requestAbs($method, $absoluteURI)
Like @see \io\vertx\jphp\core\http\HttpClient::requestAbs using the serverAddress
parameter to connect to the
server instead of the absoluteURI
parameter.
The request host header will still be created from the absoluteURI
parameter.
Use to connect to a unix domain socket server.
param $method [string]
param $serverAddress [SocketAddress]
param $absoluteURI [string]
requestAbs($method, $serverAddress, $absoluteURI)
Create an HTTP request to send to the server using an absolute URI, specifying a response handler to receive
the response
param $method [string] the HTTP method
param $absoluteURI [string] the absolute URI
param $responseHandler [callable] the response handler
requestAbs($method, $absoluteURI, $responseHandler)
Like @see \io\vertx\jphp\core\http\HttpClient::requestAbs using the serverAddress
parameter to connect to the
server instead of the absoluteURI
parameter.
The request host header will still be created from the absoluteURI
parameter.
Use to connect to a unix domain socket server. param $method [string] param $serverAddress [SocketAddress] param $absoluteURI [string] param $responseHandler [callable] requestAbs($method, $serverAddress, $absoluteURI, $responseHandler)
string
string | SocketAddress
callable | string
callable
\io\vertx\jphp\core\http\HttpClientRequest
an HTTP client request object
webSocket( $arg0, $arg1, $arg2 = null, $arg3 = null) : void
param $requestURI [string] the relative URI param $handler [callable] handler that will be called with the websocket when connected webSocket($requestURI, $handler)
Connect a WebSocket with the specified options.
param $options [array] the request options param $handler [callable] webSocket($options, $handler)
Connect a WebSocket to the host and relative request URI and default port
param $host [string] the host param $requestURI [string] the relative URI param $handler [callable] handler that will be called with the websocket when connected webSocket($host, $requestURI, $handler)
Connect a WebSocket to the specified port, host and relative request URI
param $port [integer] the port param $host [string] the host param $requestURI [string] the relative URI param $handler [callable] handler that will be called with the websocket when connected webSocket($port, $host, $requestURI, $handler)
string | array | integer
callable | string
callable | string
callable
webSocketAbs( $arg0, $arg1, $arg2, $arg3, $arg4) : void
string
MultiMap
string
array
callable