final class EventHttp (View source)

EventHttp.

Represents HTTP server.

Methods

__construct(EventBase $base, EventSslContext|null $ctx = null)

__construct.

bool
accept(mixed $socket)

accept.

bool
addServerAlias(string $alias)

addServerAlias.

bool
bind(string $address, int $port)

bind.

bool
removeServerAlias(string $alias)

removeServerAlias.

void
setAllowedMethods(int $methods)

setAllowedMethods.

bool
setCallback(string $path, string $cb, string|null $arg = null)

setCallback.

void
setDefaultCallback(string $cb, string|null $arg = null)

setDefaultCallback.

void
setMaxBodySize(int $value)

setMaxBodySize.

void
setMaxHeadersSize(int $value)

setMaxHeadersSize.

void
setTimeout(int $value)

setTimeout.

Details

__construct(EventBase $base, EventSslContext|null $ctx = null)

__construct.

Constructs EventHttp object(the HTTP server).

Parameters

EventBase $base

Associated event base.

EventSslContext|null $ctx

EventSslContext class object. Turns plain HTTP server into HTTPS server. It means that if ctx is configured correctly, then the underlying buffer events will be based on OpenSSL sockets. Thus, all traffic will pass through the SSL or TLS. This parameter is available only if Event is compiled with OpenSSL support and only with Libevent 2.1.0-alpha and higher.

See also

https://secure.php.net/manual/en/eventhttp.construct.php

bool accept(mixed $socket)

accept.

Makes an HTTP server accept connections on the specified socket stream or resource.

Parameters

mixed $socket

Socket resource, stream or numeric file descriptor representing a socket ready to accept connections.

Return Value

bool

Returns true on success or false on failure.

See also

https://secure.php.net/manual/en/eventhttp.accept.php

bool addServerAlias(string $alias)

addServerAlias.

Adds a server alias to the HTTP server object.

Parameters

string $alias

The alias to add.

Return Value

bool

Returns true on success or false on failure.

See also

https://secure.php.net/manual/en/eventhttp.addserveralias.php

bool bind(string $address, int $port)

bind.

Binds an HTTP server on the specified address and port.

Parameters

string $address

A string containing the IP address to listen(2) on.

int $port

The port number to listen on.

Return Value

bool

Returns true on success or false on failure.

See also

https://secure.php.net/manual/en/eventhttp.bind.php

bool removeServerAlias(string $alias)

removeServerAlias.

Removes server alias.

Parameters

string $alias

The alias to remove.

Return Value

bool

Returns true on success or false on failure.

See also

https://secure.php.net/manual/en/eventhttp.removeserveralias.php

void setAllowedMethods(int $methods)

setAllowedMethods.

Sets the what HTTP methods are supported in requests accepted by this server, and passed to user callbacks.

Parameters

int $methods

A bit mask of EventHttpRequest::CMD_* constants.

Return Value

void

See also

https://secure.php.net/manual/en/eventhttp.setallowedmethods.php

bool setCallback(string $path, string $cb, string|null $arg = null)

setCallback.

Sets a callback for specified URI.

Parameters

string $path

The path for which to invoke the callback.

string $cb

The callback callable that gets invoked on requested path. It should match the following prototype: void callback EventHttpRequest req NULL mixed arg NULL req EventHttpRequest object. arg Custom data.

string|null $arg (optional)

Return Value

bool

Returns true on success or false on failure.

See also

https://secure.php.net/manual/en/eventhttp.setcallback.php

void setDefaultCallback(string $cb, string|null $arg = null)

setDefaultCallback.

Sets default callback to handle requests that are not caught by specific callbacks.

Parameters

string $cb

The callback callable. It should match the following prototype: void callback EventHttpRequest req NULL mixed arg NULL req EventHttpRequest object. arg Custom data.

string|null $arg (optional)

Return Value

void

See also

https://secure.php.net/manual/en/eventhttp.setdefaultcallback.php

void setMaxBodySize(int $value)

setMaxBodySize.

Sets maximum request body size.

Parameters

int $value

The body size in bytes.

Return Value

void

See also

https://secure.php.net/manual/en/eventhttp.setmaxbodysize.php

void setMaxHeadersSize(int $value)

setMaxHeadersSize.

Sets maximum HTTP header size.

Parameters

int $value

The header size in bytes.

Return Value

void

See also

https://secure.php.net/manual/en/eventhttp.setmaxheaderssize.php

void setTimeout(int $value)

setTimeout.

Sets the timeout for an HTTP request.

Parameters

int $value

The timeout in seconds.

Return Value

void

See also

https://secure.php.net/manual/en/eventhttp.settimeout.php