Methods |
public
|
__construct(string $host, int $port, int $timeout = -1)
Creates a new HttpServer object
Creates a new HttpServer object
Parameters
$timeout |
The default number of seconds to wait for a request
before timing out. Use a negative value to wait indefinitely.
|
|
#
|
public
|
getHost(): string
Get the server's hostname or IP address
Get the server's hostname or IP address
|
#
|
public
|
getPort(): int
Get the server's TCP port
Get the server's TCP port
|
#
|
public
|
getTimeout(): int
Get the default number of seconds to wait for a request before timing out
Get the default number of seconds to wait for a request before timing out
|
#
|
public
|
hasProxy(): bool
Check if the server is configured to run behind a proxy server
Check if the server is configured to run behind a proxy server
|
#
|
public
|
getProxyHost(): string
Get the hostname or IP address of the proxy server
Get the hostname or IP address of the proxy server
|
#
|
public
|
getProxyPort(): int
Get the TCP port of the proxy server
Get the TCP port of the proxy server
|
#
|
public
|
getProxyTls(): bool
Check if connections to the proxy server are encrypted
Check if connections to the proxy server are encrypted
|
#
|
public
|
getProxyBasePath(): string
Get the base path at which the server can be reached via the proxy server
Get the base path at which the server can be reached via the proxy server
|
#
|
public
|
withProxy(string $host, int $port, ?bool $tls = null, string $basePath = ''): static
Get an instance configured to run behind a proxy server
Get an instance configured to run behind a proxy server
Returns a server that listens at the same host and port, but refers to
itself in client-facing URIs as:
http[s]://<proxy_host>[:<proxy_port>][<proxy_base_path>]
|
#
|
public
|
withoutProxy(): static
Get an instance that is not configured to run behind a proxy server
Get an instance that is not configured to run behind a proxy server
|
#
|
public
|
getBaseUri(): string
Get the server's client-facing base URI with no trailing slash
Get the server's client-facing base URI with no trailing slash
|
#
|
public
|
getScheme(): string
Get the server's client-facing URI scheme
Get the server's client-facing URI scheme
|
#
|
public
|
isRunning(): bool
Check if the server is running
Check if the server is running
|
#
|
public
|
start(): $this
Start the server
|
#
|
public
|
stop(): $this
Stop the server
|
#
|
public
|
listen<T>(
callable(HttpServerRequestInterface $request, bool& $continue, T& $return): ResponseInterface $callback,
?int $timeout = null,
): T|null
Wait for a request and return a response
Wait for a request and return a response
Parameters
$callback |
Receives
an {@see HttpServerRequestInterface} and returns a
{@see ResponseInterface}. May also set $continue = true to make
{@see HttpServer::listen()} wait for another request, or pass a value
back to the caller by assigning it to $return .
|
|
#
|