Env
class Env (View source)
The http\Env class provides static methods to manipulate and inspect the server's current request's HTTP environment.
Methods
Retrieve the current HTTP request's body.
Retrieve one or all headers of the current HTTP request.
Get the HTTP response code to send.
Get one or all HTTP response headers to be sent.
Retrieve a list of all known HTTP response status.
Retrieve the string representation of specified HTTP response code.
Generic negotiator. For specific client negotiation see http\Env::negotiateContentType() and related methods.
Negotiate the client's preferred character set.
Negotiate the client's preferred MIME content type.
Negotiate the client's preferred encoding.
Negotiate the client's preferred language.
Set the HTTP response code to send.
Set a response header, either replacing a prior set header, or appending the new header value, depending on $replace.
Details
Body
getRequestBody(string $body_class_name = null)
Retrieve the current HTTP request's body.
string|null|array
getRequestHeader(string $header_name = null)
Retrieve one or all headers of the current HTTP request.
int
getResponseCode()
Get the HTTP response code to send.
string|array|null
getResponseHeader(string $header_name = null)
Get one or all HTTP response headers to be sent.
array
getResponseStatusForAllCodes()
Retrieve a list of all known HTTP response status.
string
getResponseStatusForCode(int $code)
Retrieve the string representation of specified HTTP response code.
string|null
negotiate(string $params, array $supported, string $prim_typ_sep = null, array $result = null)
Generic negotiator. For specific client negotiation see http\Env::negotiateContentType() and related methods.
NOTE: The first element of $supported serves as a default if no operand matches.
string|null
negotiateCharset(array $supported, array $result = null)
Negotiate the client's preferred character set.
NOTE: The first element of $supported character sets serves as a default if no character set matches.
string|null
negotiateContentType(array $supported, array $result = null)
Negotiate the client's preferred MIME content type.
NOTE: The first element of $supported content types serves as a default if no content-type matches.
string|null
negotiateEncoding(array $supported, array $result = null)
Negotiate the client's preferred encoding.
NOTE: The first element of $supported encodings serves as a default if no encoding matches.
string|null
negotiateLanguage(array $supported, array $result = null)
Negotiate the client's preferred language.
NOTE: The first element of $supported languages serves as a default if no language matches.
bool
setResponseCode(int $code)
Set the HTTP response code to send.
bool
setResponseHeader(string $header_name, mixed $header_value = null, int $response_code = null, bool $replace = null)
Set a response header, either replacing a prior set header, or appending the new header value, depending on $replace.
If no $header_value is specified, or $header_value is NULL, then a previously set header with the same key will be deleted from the list.
If $response_code is not 0, the response status code is updated accordingly.