Phalcon http
NOTE
All classes are prefixed with Phalcon
Http\Cookie¶
Class Source on GitHub
Provide OO wrappers to manage a HTTP cookie.
stdClassPhalcon\Di\AbstractInjectionAwarePhalcon\Http\Cookie- implementsPhalcon\Http\Cookie\CookieInterface
Uses Phalcon\Di\AbstractInjectionAware · Phalcon\Di\DiInterface · Phalcon\Encryption\Crypt\CryptInterface · Phalcon\Filter\FilterInterface · Phalcon\Http\Cookie\CookieInterface · Phalcon\Http\Cookie\Exception · Phalcon\Http\Cookie\Exceptions\CookieKeyTooShort · Phalcon\Http\Cookie\Exceptions\CryptInterfaceRequired · Phalcon\Http\Cookie\Exceptions\CryptServiceUnavailable · Phalcon\Http\Cookie\Exceptions\FilterServiceUnavailable · Phalcon\Http\Response\Exception · Phalcon\Session\ManagerInterface
Method Summary¶
public
__construct(string $name,mixed $value = null,int $expire = 0,string $path = "/",bool $secure = false,string $domain = "",bool $httpOnly = false,array $options = [])
Phalcon\Http\Cookie constructor.
public
string
__toString()
Magic __toString method converts the cookie's value to string
public
delete()
Deletes the cookie by setting an expire time in the past
public
string
getDomain()
Returns the domain that the cookie is available to
public
int
getExpiration()
Returns the current expiration time
public
bool
getHttpOnly()
Returns if the cookie is accessible only through the HTTP protocol
public
string
getName()
Returns the current cookie's name
public
array
getOptions()
Returns the current cookie's options
public
string
getPath()
Returns the current cookie's path
public
bool
getSecure()
Returns whether the cookie must only be sent when the connection is
public
mixed
getValue(mixed $filters = null,mixed $defaultValue = null)
Returns the cookie's value.
public
bool
isUsingEncryption()
Check if the cookie is using implicit encryption
public
CookieInterface
restore()
Reads the cookie-related info from the SESSION to restore the cookie as
public
CookieInterface
send()
Sends the cookie to the HTTP client.
public
CookieInterface
setDomain( string $domain )
Sets the domain that the cookie is available to
public
CookieInterface
setExpiration( int $expire )
Sets the cookie's expiration time
public
CookieInterface
setHttpOnly( bool $httpOnly )
Sets if the cookie is accessible only through the HTTP protocol
public
CookieInterface
setOptions( array $options )
Sets the cookie's options
public
CookieInterface
setPath( string $path )
Sets the cookie's path
public
CookieInterface
setSecure( bool $secure )
Sets if the cookie must only be sent when the connection is secure (HTTPS)
public
CookieInterface
setSignKey( string $signKey = null )
Sets the cookie's sign key.
public
CookieInterface
setValue( mixed $value )
Sets the cookie's value
public
CookieInterface
useEncryption( bool $useEncryption )
Sets if the cookie must be encrypted/decrypted automatically
protected
void
assertSignKeyIsLongEnough( string $signKey )
Assert the cookie's key is enough long.
Properties¶
protected
string
$domain
protected
int
$expire
protected
FilterInterface|null
$filter = null
protected
bool
$httpOnly
protected
bool
$isRead = false
protected
bool
$isRestored = false
protected
string
$name
protected
array
$options = []
protected
string
$path
protected
bool
$secure = true
protected
string|null
$signKey = null
The cookie's sign key.
protected
bool
$useEncryption = false
protected
mixed|null
$value = null
Methods¶
__construct()¶
public function __construct(
string $name,
mixed $value = null,
int $expire = 0,
string $path = "/",
bool $secure = false,
string $domain = "",
bool $httpOnly = false,
array $options = []
);
Phalcon\Http\Cookie constructor.
__toString()¶
Magic __toString method converts the cookie's value to string
delete()¶
Deletes the cookie by setting an expire time in the past
getDomain()¶
Returns the domain that the cookie is available to
getExpiration()¶
Returns the current expiration time
getHttpOnly()¶
Returns if the cookie is accessible only through the HTTP protocol
getName()¶
Returns the current cookie's name
getOptions()¶
Returns the current cookie's options
getPath()¶
Returns the current cookie's path
getSecure()¶
Returns whether the cookie must only be sent when the connection is secure (HTTPS)
getValue()¶
Returns the cookie's value.
isUsingEncryption()¶
Check if the cookie is using implicit encryption
restore()¶
Reads the cookie-related info from the SESSION to restore the cookie as it was set.
This method is automatically called internally so normally you don't need to call it.
send()¶
Sends the cookie to the HTTP client.
Stores the cookie definition in session.
setDomain()¶
Sets the domain that the cookie is available to
setExpiration()¶
Sets the cookie's expiration time
setHttpOnly()¶
Sets if the cookie is accessible only through the HTTP protocol
setOptions()¶
Sets the cookie's options
setPath()¶
Sets the cookie's path
setSecure()¶
Sets if the cookie must only be sent when the connection is secure (HTTPS)
setSignKey()¶
Sets the cookie's sign key.
The `$signKey' MUST be at least 32 characters long and generated using a cryptographically secure pseudo random generator.
Use NULL to disable cookie signing.
@see \Phalcon\Encryption\Security\Random
setValue()¶
Sets the cookie's value
useEncryption()¶
Sets if the cookie must be encrypted/decrypted automatically
assertSignKeyIsLongEnough()¶
Assert the cookie's key is enough long.
Http\Cookie\CookieInterface¶
Interface Source on GitHub
Interface for Phalcon\Http\Cookie
Phalcon\Http\Cookie\CookieInterface
Method Summary¶
public
delete()
Deletes the cookie
public
string
getDomain()
Returns the domain that the cookie is available to
public
int
getExpiration()
Returns the current expiration time
public
bool
getHttpOnly()
Returns if the cookie is accessible only through the HTTP protocol
public
string
getName()
Returns the current cookie's name
public
array
getOptions()
Returns the current cookie's options
public
string
getPath()
Returns the current cookie's path
public
bool
getSecure()
Returns whether the cookie must only be sent when the connection is
public
mixed
getValue(mixed $filters = null,mixed $defaultValue = null)
Returns the cookie's value.
public
bool
isUsingEncryption()
Check if the cookie is using implicit encryption
public
CookieInterface
send()
Sends the cookie to the HTTP client
public
CookieInterface
setDomain( string $domain )
Sets the domain that the cookie is available to
public
CookieInterface
setExpiration( int $expire )
Sets the cookie's expiration time
public
CookieInterface
setHttpOnly( bool $httpOnly )
Sets if the cookie is accessible only through the HTTP protocol
public
CookieInterface
setOptions( array $options )
Sets the cookie's options
public
CookieInterface
setPath( string $path )
Sets the cookie's expiration time
public
CookieInterface
setSecure( bool $secure )
Sets if the cookie must only be sent when the connection is secure
public
CookieInterface
setValue( mixed $value )
Sets the cookie's value
public
CookieInterface
useEncryption( bool $useEncryption )
Sets if the cookie must be encrypted/decrypted automatically
Methods¶
delete()¶
Deletes the cookie
getDomain()¶
Returns the domain that the cookie is available to
getExpiration()¶
Returns the current expiration time
getHttpOnly()¶
Returns if the cookie is accessible only through the HTTP protocol
getName()¶
Returns the current cookie's name
getOptions()¶
Returns the current cookie's options
getPath()¶
Returns the current cookie's path
getSecure()¶
Returns whether the cookie must only be sent when the connection is secure (HTTPS)
getValue()¶
Returns the cookie's value.
isUsingEncryption()¶
Check if the cookie is using implicit encryption
send()¶
Sends the cookie to the HTTP client
setDomain()¶
Sets the domain that the cookie is available to
setExpiration()¶
Sets the cookie's expiration time
setHttpOnly()¶
Sets if the cookie is accessible only through the HTTP protocol
setOptions()¶
Sets the cookie's options
setPath()¶
Sets the cookie's expiration time
setSecure()¶
Sets if the cookie must only be sent when the connection is secure (HTTPS)
setValue()¶
Sets the cookie's value
useEncryption()¶
Sets if the cookie must be encrypted/decrypted automatically
Http\Cookie\Exception¶
Class Source on GitHub
Phalcon\Http\Cookie\Exception
Exceptions thrown in Phalcon\Http\Cookie will use this class.
Http\Cookie\Exceptions\CookieKeyTooShort¶
Class Source on GitHub
\ExceptionPhalcon\Http\Cookie\ExceptionPhalcon\Http\Cookie\Exceptions\CookieKeyTooShort
Uses Phalcon\Http\Cookie\Exception
Method Summary¶
Methods¶
__construct()¶
Http\Cookie\Exceptions\CryptInterfaceRequired¶
Class Source on GitHub
\ExceptionPhalcon\Http\Cookie\ExceptionPhalcon\Http\Cookie\Exceptions\CryptInterfaceRequired
Uses Phalcon\Http\Cookie\Exception
Method Summary¶
Methods¶
__construct()¶
Http\Cookie\Exceptions\CryptServiceUnavailable¶
Class Source on GitHub
\ExceptionPhalcon\Http\Cookie\ExceptionPhalcon\Http\Cookie\Exceptions\CryptServiceUnavailable
Uses Phalcon\Http\Cookie\Exception
Method Summary¶
Methods¶
__construct()¶
Http\Cookie\Exceptions\FilterServiceUnavailable¶
Class Source on GitHub
\ExceptionPhalcon\Http\Cookie\ExceptionPhalcon\Http\Cookie\Exceptions\FilterServiceUnavailable
Uses Phalcon\Http\Cookie\Exception
Method Summary¶
Methods¶
__construct()¶
Http\Message\RequestMethodInterface¶
Interface Source on GitHub
Interface for Request methods
Implementation of this file has been influenced by PHP FIG @link https://github.com/php-fig/http-message-util/ @license https://github.com/php-fig/http-message-util/blob/master/LICENSE
Phalcon\Http\Message\RequestMethodInterface
Constants¶
string
METHOD_CONNECT = "CONNECT"
string
METHOD_DELETE = "DELETE"
string
METHOD_GET = "GET"
string
METHOD_HEAD = "HEAD"
string
METHOD_OPTIONS = "OPTIONS"
string
METHOD_PATCH = "PATCH"
string
METHOD_POST = "POST"
string
METHOD_PURGE = "PURGE"
string
METHOD_PUT = "PUT"
string
METHOD_TRACE = "TRACE"
Http\Message\ResponseStatusCodeInterface¶
Interface Source on GitHub
Interface for Request methods
Implementation of this file has been influenced by PHP FIG @link https://github.com/php-fig/http-message-util/ @license https://github.com/php-fig/http-message-util/blob/master/LICENSE
Defines constants for common HTTP status code.
@see https://tools.ietf.org/html/rfc2295#section-8.1 @see https://tools.ietf.org/html/rfc2324#section-2.3 @see https://tools.ietf.org/html/rfc2518#section-9.7 @see https://tools.ietf.org/html/rfc2774#section-7 @see https://tools.ietf.org/html/rfc3229#section-10.4 @see https://tools.ietf.org/html/rfc4918#section-11 @see https://tools.ietf.org/html/rfc5842#section-7.1 @see https://tools.ietf.org/html/rfc5842#section-7.2 @see https://tools.ietf.org/html/rfc6585#section-3 @see https://tools.ietf.org/html/rfc6585#section-4 @see https://tools.ietf.org/html/rfc6585#section-5 @see https://tools.ietf.org/html/rfc6585#section-6 @see https://tools.ietf.org/html/rfc7231#section-6 @see https://tools.ietf.org/html/rfc7238#section-3 @see https://tools.ietf.org/html/rfc7725#section-3 @see https://tools.ietf.org/html/rfc7540#section-9.1.2 @see https://tools.ietf.org/html/rfc8297#section-2 @see https://tools.ietf.org/html/rfc8470#section-7
Phalcon\Http\Message\ResponseStatusCodeInterface
Constants¶
int
STATUS_ACCEPTED = 202
int
STATUS_ALREADY_REPORTED = 208
int
STATUS_BAD_GATEWAY = 502
int
STATUS_BAD_REQUEST = 400
int
STATUS_BANDWIDTH_LIMIT_EXCEEDED = 509
int
STATUS_BLOCKED_BY_WINDOWS_PARENTAL_CONTROLS = 450
int
STATUS_CLIENT_CLOSED_REQUEST = 499
int
STATUS_CONFLICT = 409
int
STATUS_CONNECTION_TIMEOUT = 522
int
STATUS_CONTINUE = 100
int
STATUS_CREATED = 201
int
STATUS_EARLY_HINTS = 103
int
STATUS_EXPECTATION_FAILED = 417
int
STATUS_FAILED_DEPENDENCY = 424
int
STATUS_FORBIDDEN = 403
int
STATUS_FOUND = 302
int
STATUS_GATEWAY_TIMEOUT = 504
int
STATUS_GONE = 410
int
STATUS_HTTP_REQUEST_SENT_TO_HTTPS_PORT = 497
int
STATUS_IM_A_TEAPOT = 418
int
STATUS_IM_USED = 226
int
STATUS_INSUFFICIENT_STORAGE = 507
int
STATUS_INTERNAL_SERVER_ERROR = 500
int
STATUS_INVALID_SSL_CERTIFICATE = 526
int
STATUS_INVALID_TOKEN_ESRI = 498
int
STATUS_LENGTH_REQUIRED = 411
int
STATUS_LOCKED = 423
int
STATUS_LOGIN_TIMEOUT = 440
int
STATUS_LOOP_DETECTED = 508
int
STATUS_METHOD_FAILURE = 420
int
STATUS_METHOD_NOT_ALLOWED = 405
int
STATUS_MISDIRECTED_REQUEST = 421
int
STATUS_MOVED_PERMANENTLY = 301
int
STATUS_MULTIPLE_CHOICES = 300
int
STATUS_MULTI_STATUS = 207
int
STATUS_NETWORK_AUTHENTICATION_REQUIRED = 511
int
STATUS_NETWORK_CONNECT_TIMEOUT_ERROR = 599
int
STATUS_NETWORK_READ_TIMEOUT_ERROR = 598
int
STATUS_NON_AUTHORITATIVE_INFORMATION = 203
int
STATUS_NOT_ACCEPTABLE = 406
int
STATUS_NOT_EXTENDED = 510
int
STATUS_NOT_FOUND = 404
int
STATUS_NOT_IMPLEMENTED = 501
int
STATUS_NOT_MODIFIED = 304
int
STATUS_NO_CONTENT = 204
int
STATUS_NO_RESPONSE = 444
int
STATUS_OK = 200
int
STATUS_ORIGIN_DNS_ERROR = 530
int
STATUS_ORIGIN_IS_UNREACHABLE = 523
int
STATUS_PAGE_EXPIRED = 419
int
STATUS_PARTIAL_CONTENT = 206
int
STATUS_PAYLOAD_TOO_LARGE = 413
int
STATUS_PAYMENT_REQUIRED = 402
int
STATUS_PERMANENT_REDIRECT = 308
int
STATUS_PRECONDITION_FAILED = 412
int
STATUS_PRECONDITION_REQUIRED = 428
int
STATUS_PROCESSING = 102
int
STATUS_PROXY_AUTHENTICATION_REQUIRED = 407
int
STATUS_RAILGUN_ERROR = 527
int
STATUS_RANGE_NOT_SATISFIABLE = 416
int
STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE = 431
int
STATUS_REQUEST_HEADER_TOO_LARGE = 494
int
STATUS_REQUEST_TIMEOUT = 408
int
STATUS_RESERVED = 306
int
STATUS_RESET_CONTENT = 205
int
STATUS_RETRY_WITH = 449
int
STATUS_SEE_OTHER = 303
int
STATUS_SERVICE_UNAVAILABLE = 503
int
STATUS_SSL_CERTIFICATE_ERROR = 495
int
STATUS_SSL_CERTIFICATE_REQUIRED = 496
int
STATUS_SSL_HANDSHAKE_FAILED = 525
int
STATUS_SWITCHING_PROTOCOLS = 101
int
STATUS_TEMPORARY_REDIRECT = 307
int
STATUS_THIS_IS_FINE = 218
int
STATUS_TIMEOUT_OCCURRED = 524
int
STATUS_TOO_EARLY = 425
int
STATUS_TOO_MANY_REQUESTS = 429
int
STATUS_UNAUTHORIZED = 401
int
STATUS_UNAVAILABLE_FOR_LEGAL_REASONS = 451
int
STATUS_UNKNOWN_ERROR = 520
int
STATUS_UNPROCESSABLE_ENTITY = 422
int
STATUS_UNSUPPORTED_MEDIA_TYPE = 415
int
STATUS_UPGRADE_REQUIRED = 426
int
STATUS_URI_TOO_LONG = 414
int
STATUS_USE_PROXY = 305
int
STATUS_VARIANT_ALSO_NEGOTIATES = 506
int
STATUS_VERSION_NOT_SUPPORTED = 505
int
STATUS_WEB_SERVER_IS_DOWN = 521
Http\Request¶
Class Source on GitHub
Encapsulates request information for easy and secure access from application controllers.
The request object is a simple value object that is passed between the dispatcher and controller classes. It packages the HTTP request environment.
use Phalcon\Http\Request;
$request = new Request();
if ($request->isPost() && $request->isAjax()) {
echo "Request was made using POST and AJAX";
}
// Retrieve SERVER variables
$request->getServer("HTTP_HOST");
// GET, POST, PUT, DELETE, HEAD, OPTIONS, PATCH, PURGE, TRACE, CONNECT
$request->getMethod();
// An array of languages the client accepts
$request->getLanguages();
stdClassPhalcon\Di\AbstractInjectionAwarePhalcon\Http\Request- implementsPhalcon\Http\RequestInterface,Phalcon\Http\Message\RequestMethodInterface
Uses Phalcon\Di\AbstractInjectionAware · Phalcon\Di\DiInterface · Phalcon\Events\ManagerInterface · Phalcon\Filter\FilterInterface · Phalcon\Http\Message\RequestMethodInterface · Phalcon\Http\Request\Exception · Phalcon\Http\Request\Exceptions\FilterServiceUnavailable · Phalcon\Http\Request\Exceptions\InvalidHost · Phalcon\Http\Request\Exceptions\InvalidHttpMethod · Phalcon\Http\Request\Exceptions\MissingFilters · Phalcon\Http\Request\Exceptions\SanitizerNotFound · Phalcon\Http\Request\File · Phalcon\Http\Request\FileInterface · Phalcon\Support\Helper\Json\Decode · stdClass
Method Summary¶
public
mixed
get(string $name = null,mixed $filters = null,mixed $defaultValue = null,bool $notAllowEmpty = false,bool $noRecursive = false)
Gets a variable from the $_REQUEST superglobal applying filters if
public
array
getAcceptableContent()
Gets an array with mime/types and their quality accepted by the
public
array|null
getBasicAuth()
Gets auth info accepted by the browser/client from
public
string
getBestAccept()
Gets best mime/type accepted by the browser/client from
public
string
getBestCharset()
Gets best charset accepted by the browser/client from
public
string
getBestLanguage()
Gets best language accepted by the browser/client from
public
string|bool
getClientAddress( bool $trustForwardedHeader = false )
Gets most possible client IP Address. This method searches in
public
array
getClientCharsets()
Gets a charsets array and their quality accepted by the browser/client
public
string|null
getContentType()
Gets content type which request has been made
public
array
getDigestAuth()
Gets auth info accepted by the browser/client from
public
mixed
getFilteredData(string $methodKey,string $method,string $name = null,mixed $defaultValue = null,bool $notAllowEmpty = false,bool $noRecursive = false)
Gets filtered data
public
mixed
getFilteredPatch(string $name = null,mixed $defaultValue = null,bool $notAllowEmpty = false,bool $noRecursive = false)
Retrieves a patch value always sanitized with the preset filters
public
mixed
getFilteredPost(string $name = null,mixed $defaultValue = null,bool $notAllowEmpty = false,bool $noRecursive = false)
Retrieves a post value always sanitized with the preset filters
public
mixed
getFilteredPut(string $name = null,mixed $defaultValue = null,bool $notAllowEmpty = false,bool $noRecursive = false)
Retrieves a put value always sanitized with the preset filters
public
mixed
getFilteredQuery(string $name = null,mixed $defaultValue = null,bool $notAllowEmpty = false,bool $noRecursive = false)
Retrieves a query/get value always sanitized with the preset filters
public
string
getHTTPReferer()
Gets web page that refers active request. ie: http://www.google.com
public
string
getHeader( string $header )
Gets HTTP header from request data
public
array
getHeaders()
Returns the available headers in the request
public
string
getHttpHost()
Gets host name used by the request.
public
bool
getHttpMethodParameterOverride()
Return the HTTP method parameter override flag
public
\stdClass|array|bool
getJsonRawBody( bool $associative = false )
Gets decoded JSON HTTP raw request body
public
array
getLanguages()
Gets languages array and their quality accepted by the browser/client
public
string
getMethod()
Gets HTTP method which request has been made
public
mixed
getPatch(string $name = null,mixed $filters = null,mixed $defaultValue = null,bool $notAllowEmpty = false,bool $noRecursive = false)
Gets a variable from put request
public
int
getPort()
Gets information about the port on which the request is made.
public
mixed
getPost(string $name = null,mixed $filters = null,mixed $defaultValue = null,bool $notAllowEmpty = false,bool $noRecursive = false)
Gets a variable from the $_POST superglobal applying filters if needed
public
string
getPreferredIsoLocaleVariant()
Gets the preferred ISO locale variant.
public
mixed
getPut(string $name = null,mixed $filters = null,mixed $defaultValue = null,bool $notAllowEmpty = false,bool $noRecursive = false)
Gets a variable from the PUT request
public
mixed
getQuery(string $name = null,mixed $filters = null,mixed $defaultValue = null,bool $notAllowEmpty = false,bool $noRecursive = false)
Gets variable from $_GET superglobal applying filters if needed
public
string
getRawBody()
Gets HTTP raw request body
public
string
getScheme()
Gets HTTP schema (http/https)
public
string|null
getServer( string $name )
Gets variable from $_SERVER superglobal
public
string
getServerAddress()
Gets active server address IP
public
string
getServerName()
Gets active server name
public
string
getURI( bool $onlyPath = false )
Gets HTTP URI which request has been made to
public
FileInterface[]
getUploadedFiles(bool $onlySuccessful = false,bool $namedKeys = false)
Gets attached files as Phalcon\Http\Request\File instances
public
string
getUserAgent()
Gets HTTP user agent used to made the request
public
bool
has( string $name )
Checks whether $_REQUEST superglobal has certain index
public
bool
hasFiles()
Returns if the request has files or not
public
bool
hasHeader( string $header )
Checks whether headers has certain index
public
bool
hasPatch( string $name )
Checks whether the PATCH data has certain index
public
bool
hasPost( string $name )
Checks whether $_POST superglobal has certain index
public
bool
hasPut( string $name )
Checks whether the PUT data has certain index
public
bool
hasQuery( string $name )
Checks whether $_GET superglobal has certain index
public
bool
hasServer( string $name )
Checks whether $_SERVER superglobal has certain index
public
bool
isAjax()
Checks whether request has been made using ajax
public
bool
isConnect()
Checks whether HTTP method is CONNECT.
public
bool
isDelete()
Checks whether HTTP method is DELETE.
public
bool
isGet()
Checks whether HTTP method is GET.
public
bool
isHead()
Checks whether HTTP method is HEAD.
public
bool
isJson()
Checks whether request content type contains json data
public
bool
isMethod(mixed $methods,bool $strict = false)
Check if HTTP method match any of the passed methods
public
bool
isOptions()
Checks whether HTTP method is OPTIONS.
public
bool
isPatch()
Checks whether HTTP method is PATCH.
public
bool
isPost()
Checks whether HTTP method is POST.
public
bool
isPurge()
Checks whether HTTP method is PURGE (Squid and Varnish support).
public
bool
isPut()
Checks whether HTTP method is PUT.
public
bool
isSecure()
Checks whether request has been made using any secure layer
public
bool
isSoap()
Checks whether request has been made using SOAP
public
bool
isStrictHostCheck()
Checks if the Request::getHttpHost method will be use strict validation
public
bool
isTrace()
Checks whether HTTP method is TRACE.
public
bool
isValidHttpMethod( string $method )
Checks if a method is a valid HTTP method
public
long
numFiles( bool $onlySuccessful = false )
Returns the number of files available
public
static
setHttpMethodParameterOverride( bool $override )
Set the HTTP method parameter override flag
public
static
setParameterFilters(string $name,array $filters = [],array $scope = [])
Sets automatic sanitizers/filters for a particular field and for
public
static
setStrictHostCheck( bool $flag = true )
Sets if the Request::getHttpHost method must be use strict validation
public
static
setTrustedProxies( array $trustedProxies )
Set a trusted proxy list for X-Forwarded-For header
public
static
setTrustedProxyHeader( string $trustedProxyHeader )
This header takes priority when parsing HTTP headers
protected
string
getBestQuality(array $qualityParts,string $name)
Process a request header and return the one with best quality
protected
mixed
getHelper(array $source,string $name = null,mixed $filters = null,mixed $defaultValue = null,bool $notAllowEmpty = false,bool $noRecursive = false)
Helper to get data from superglobals, applying filters if needed.
protected
array
getQualityHeader(string $serverIndex,string $name)
Process a request header and return an array of values with their qualities
protected
long
hasFileHelper(mixed $data,bool $onlySuccessful)
Recursively counts file in an array of files
protected
bool
isIpAddressInCIDR(string $ip,string $cidr)
Check if an IP address exists in CIDR range
protected
array
resolveAuthorizationHeaders()
Resolve authorization headers.
protected
array
smoothFiles(array $names,array $types,array $tmp_names,array $sizes,array $errors,string $prefix)
Smooth out $_FILES to have plain array with all files uploaded
Properties¶
protected
FilterInterface|null
$filterService = null
protected
bool
$methodOverride = false
protected
array|null
$postCache = null
protected
array
$queryFilters = []
protected
string
$rawBody = ""
protected
bool
$strictHostCheck = false
protected
array
$trustedProxies = []
protected
string
$trustedProxyHeader = ""
Methods¶
get()¶
public function get(
string $name = null,
mixed $filters = null,
mixed $defaultValue = null,
bool $notAllowEmpty = false,
bool $noRecursive = false
): mixed;
Gets a variable from the $_REQUEST superglobal applying filters if needed. If no parameters are given the $_REQUEST superglobal is returned
// Returns value from $_REQUEST["user_email"] without sanitizing
$userEmail = $request->get("user_email");
// Returns value from $_REQUEST["user_email"] with sanitizing
$userEmail = $request->get("user_email", "email");
getAcceptableContent()¶
Gets an array with mime/types and their quality accepted by the browser/client from _SERVER["HTTP_ACCEPT"]
getBasicAuth()¶
Gets auth info accepted by the browser/client from $_SERVER["PHP_AUTH_USER"]
getBestAccept()¶
Gets best mime/type accepted by the browser/client from _SERVER["HTTP_ACCEPT"]
getBestCharset()¶
Gets best charset accepted by the browser/client from _SERVER["HTTP_ACCEPT_CHARSET"]
getBestLanguage()¶
Gets best language accepted by the browser/client from _SERVER["HTTP_ACCEPT_LANGUAGE"]
getClientAddress()¶
Gets most possible client IP Address. This method searches in
$_SERVER["REMOTE_ADDR"] and optionally in
$_SERVER["HTTP_X_FORWARDED_FOR"] and returns the first non-private or non-reserved IP address
The user provided trusted header takes priority before checking X-Forwarded-For header.
Using trusted proxies list, user has to provide a trusted list of proxy IPs
Using user provided trusted header, header should only ever contain 1 IP address, eg. HTTP_CLIENT_IP$request
->setTrustedProxyHeader('HTTP_CLIENT_IP')
->setTrustedProxies($trustedProxies)
->getClientAddress(true);
getClientCharsets()¶
Gets a charsets array and their quality accepted by the browser/client from _SERVER["HTTP_ACCEPT_CHARSET"]
getContentType()¶
Gets content type which request has been made
getDigestAuth()¶
Gets auth info accepted by the browser/client from $_SERVER["PHP_AUTH_DIGEST"]
getFilteredData()¶
public function getFilteredData(
string $methodKey,
string $method,
string $name = null,
mixed $defaultValue = null,
bool $notAllowEmpty = false,
bool $noRecursive = false
): mixed;
Gets filtered data
getFilteredPatch()¶
public function getFilteredPatch(
string $name = null,
mixed $defaultValue = null,
bool $notAllowEmpty = false,
bool $noRecursive = false
): mixed;
Retrieves a patch value always sanitized with the preset filters
getFilteredPost()¶
public function getFilteredPost(
string $name = null,
mixed $defaultValue = null,
bool $notAllowEmpty = false,
bool $noRecursive = false
): mixed;
Retrieves a post value always sanitized with the preset filters
getFilteredPut()¶
public function getFilteredPut(
string $name = null,
mixed $defaultValue = null,
bool $notAllowEmpty = false,
bool $noRecursive = false
): mixed;
Retrieves a put value always sanitized with the preset filters
getFilteredQuery()¶
public function getFilteredQuery(
string $name = null,
mixed $defaultValue = null,
bool $notAllowEmpty = false,
bool $noRecursive = false
): mixed;
Retrieves a query/get value always sanitized with the preset filters
getHTTPReferer()¶
Gets web page that refers active request. ie: http://www.google.com
getHeader()¶
Gets HTTP header from request data
getHeaders()¶
Returns the available headers in the request
$_SERVER = [
"PHP_AUTH_USER" => "phalcon",
"PHP_AUTH_PW" => "secret",
];
$headers = $request->getHeaders();
echo $headers["Authorization"]; // Basic cGhhbGNvbjpzZWNyZXQ=
getHttpHost()¶
Gets host name used by the request.
Request::getHttpHost trying to find host name in following order:
$_SERVER["HTTP_HOST"]$_SERVER["SERVER_NAME"]$_SERVER["SERVER_ADDR"]
Optionally Request::getHttpHost validates and clean host name.
The Request::$strictHostCheck can be used to validate host name.
Note: validation and cleaning have a negative performance impact because they use regular expressions.
use Phalcon\Http\Request;
$request = new Request;
$_SERVER["HTTP_HOST"] = "example.com";
$request->getHttpHost(); // example.com
$_SERVER["HTTP_HOST"] = "example.com:8080";
$request->getHttpHost(); // example.com:8080
$request->setStrictHostCheck(true);
$_SERVER["HTTP_HOST"] = "ex=am~ple.com";
$request->getHttpHost(); // UnexpectedValueException
$_SERVER["HTTP_HOST"] = "ExAmPlE.com";
$request->getHttpHost(); // example.com
getHttpMethodParameterOverride()¶
Return the HTTP method parameter override flag
getJsonRawBody()¶
Gets decoded JSON HTTP raw request body
getLanguages()¶
Gets languages array and their quality accepted by the browser/client from _SERVER["HTTP_ACCEPT_LANGUAGE"]
getMethod()¶
Gets HTTP method which request has been made
If the X-HTTP-Method-Override header is set, and if the method is a POST, then it is used to determine the "real" intended HTTP method.
The _method request parameter can also be used to determine the HTTP method, but only if setHttpMethodParameterOverride(true) has been called.
The method is always an uppercased string.
getPatch()¶
public function getPatch(
string $name = null,
mixed $filters = null,
mixed $defaultValue = null,
bool $notAllowEmpty = false,
bool $noRecursive = false
): mixed;
Gets a variable from put request
// Returns value from $_PATCH["user_email"] without sanitizing
$userEmail = $request->getPatch("user_email");
// Returns value from $_PATCH["user_email"] with sanitizing
$userEmail = $request->getPatch("user_email", "email");
getPort()¶
Gets information about the port on which the request is made.
getPost()¶
public function getPost(
string $name = null,
mixed $filters = null,
mixed $defaultValue = null,
bool $notAllowEmpty = false,
bool $noRecursive = false
): mixed;
Gets a variable from the $_POST superglobal applying filters if needed If no parameters are given the $_POST superglobal is returned
// Returns value from $_POST["user_email"] without sanitizing
$userEmail = $request->getPost("user_email");
// Returns value from $_POST["user_email"] with sanitizing
$userEmail = $request->getPost("user_email", "email");
getPreferredIsoLocaleVariant()¶
Gets the preferred ISO locale variant.
Gets the preferred locale accepted by the client from the
"Accept-Language" request HTTP header and returns the
base part of it i.e. en instead of en-US.
Note: This method relies on the $_SERVER["HTTP_ACCEPT_LANGUAGE"] header.
@link https://www.iso.org/standard/50707.html
getPut()¶
public function getPut(
string $name = null,
mixed $filters = null,
mixed $defaultValue = null,
bool $notAllowEmpty = false,
bool $noRecursive = false
): mixed;
Gets a variable from the PUT request
// Returns value from PUT stream without sanitizing
$userEmail = $request->getPut("user_email");
// Returns value from PUT stream with sanitizing
$userEmail = $request->getPut("user_email", "email");
getQuery()¶
public function getQuery(
string $name = null,
mixed $filters = null,
mixed $defaultValue = null,
bool $notAllowEmpty = false,
bool $noRecursive = false
): mixed;
Gets variable from $_GET superglobal applying filters if needed If no parameters are given the $_GET superglobal is returned
// Returns value from $_GET["id"] without sanitizing
$id = $request->getQuery("id");
// Returns value from $_GET["id"] with sanitizing
$id = $request->getQuery("id", "int");
// Returns value from $_GET["id"] with a default value
$id = $request->getQuery("id", null, 150);
getRawBody()¶
Gets HTTP raw request body
getScheme()¶
Gets HTTP schema (http/https)
getServer()¶
Gets variable from $_SERVER superglobal
getServerAddress()¶
Gets active server address IP
getServerName()¶
Gets active server name
getURI()¶
Gets HTTP URI which request has been made to
// Returns /some/path?with=queryParams
$uri = $request->getURI();
// Returns /some/path
$uri = $request->getURI(true);
getUploadedFiles()¶
public function getUploadedFiles(
bool $onlySuccessful = false,
bool $namedKeys = false
): FileInterface[];
Gets attached files as Phalcon\Http\Request\File instances
getUserAgent()¶
Gets HTTP user agent used to made the request
has()¶
Checks whether $_REQUEST superglobal has certain index
hasFiles()¶
Returns if the request has files or not
hasHeader()¶
Checks whether headers has certain index
hasPatch()¶
Checks whether the PATCH data has certain index
hasPost()¶
Checks whether $_POST superglobal has certain index
hasPut()¶
Checks whether the PUT data has certain index
hasQuery()¶
Checks whether $_GET superglobal has certain index
hasServer()¶
Checks whether $_SERVER superglobal has certain index
isAjax()¶
Checks whether request has been made using ajax
isConnect()¶
Checks whether HTTP method is CONNECT. if _SERVER["REQUEST_METHOD"]==="CONNECT"
isDelete()¶
Checks whether HTTP method is DELETE. if _SERVER["REQUEST_METHOD"]==="DELETE"
isGet()¶
Checks whether HTTP method is GET. if _SERVER["REQUEST_METHOD"]==="GET"
isHead()¶
Checks whether HTTP method is HEAD. if _SERVER["REQUEST_METHOD"]==="HEAD"
isJson()¶
Checks whether request content type contains json data
isMethod()¶
Check if HTTP method match any of the passed methods When strict is true it checks if validated methods are real HTTP methods
isOptions()¶
Checks whether HTTP method is OPTIONS. if _SERVER["REQUEST_METHOD"]==="OPTIONS"
isPatch()¶
Checks whether HTTP method is PATCH. if _SERVER["REQUEST_METHOD"]==="PATCH"
isPost()¶
Checks whether HTTP method is POST. if _SERVER["REQUEST_METHOD"]==="POST"
isPurge()¶
Checks whether HTTP method is PURGE (Squid and Varnish support). if _SERVER["REQUEST_METHOD"]==="PURGE"
isPut()¶
Checks whether HTTP method is PUT. if _SERVER["REQUEST_METHOD"]==="PUT"
isSecure()¶
Checks whether request has been made using any secure layer
isSoap()¶
Checks whether request has been made using SOAP
isStrictHostCheck()¶
Checks if the Request::getHttpHost method will be use strict validation
of host name or not
isTrace()¶
Checks whether HTTP method is TRACE. if _SERVER["REQUEST_METHOD"]==="TRACE"
isValidHttpMethod()¶
Checks if a method is a valid HTTP method
numFiles()¶
Returns the number of files available
setHttpMethodParameterOverride()¶
Set the HTTP method parameter override flag
setParameterFilters()¶
public function setParameterFilters(
string $name,
array $filters = [],
array $scope = []
): static;
Sets automatic sanitizers/filters for a particular field and for particular methods
setStrictHostCheck()¶
Sets if the Request::getHttpHost method must be use strict validation
of host name or not
setTrustedProxies()¶
Set a trusted proxy list for X-Forwarded-For header
setTrustedProxyHeader()¶
This header takes priority when parsing HTTP headers The header return only 1 single IP address, prefixed with HTTP_ eg. HTTP_CLIENT_IP.
getBestQuality()¶
Process a request header and return the one with best quality
getHelper()¶
protected function getHelper(
array $source,
string $name = null,
mixed $filters = null,
mixed $defaultValue = null,
bool $notAllowEmpty = false,
bool $noRecursive = false
): mixed;
Helper to get data from superglobals, applying filters if needed. If no parameters are given the superglobal is returned.
getQualityHeader()¶
Process a request header and return an array of values with their qualities
hasFileHelper()¶
Recursively counts file in an array of files
isIpAddressInCIDR()¶
Check if an IP address exists in CIDR range
resolveAuthorizationHeaders()¶
Resolve authorization headers.
smoothFiles()¶
protected function smoothFiles(
array $names,
array $types,
array $tmp_names,
array $sizes,
array $errors,
string $prefix
): array;
Smooth out $_FILES to have plain array with all files uploaded
Http\RequestInterface¶
Interface Source on GitHub
Interface for Phalcon\Http\Request
Phalcon\Http\RequestInterface
Uses Phalcon\Http\Request\FileInterface · stdClass
Method Summary¶
public
mixed
get(string $name = null,mixed $filters = null,mixed $defaultValue = null,bool $notAllowEmpty = false,bool $noRecursive = false)
Gets a variable from the $_REQUEST superglobal applying filters if
public
array
getAcceptableContent()
Gets an array with mime/types and their quality accepted by the
public
array|null
getBasicAuth()
Gets auth info accepted by the browser/client from
public
string
getBestAccept()
Gets best mime/type accepted by the browser/client from
public
string
getBestCharset()
Gets best charset accepted by the browser/client from
public
string
getBestLanguage()
Gets best language accepted by the browser/client from
public
string|bool
getClientAddress( bool $trustForwardedHeader = false )
Gets most possible client IPv4 Address. This method searches in
public
array
getClientCharsets()
Gets a charsets array and their quality accepted by the browser/client
public
string|null
getContentType()
Gets content type which request has been made
public
array
getDigestAuth()
Gets auth info accepted by the browser/client from
public
string
getHTTPReferer()
Gets web page that refers active request. ie: http://www.google.com
public
string
getHeader( string $header )
Gets HTTP header from request data
public
array
getHeaders()
Returns the available headers in the request
public
string
getHttpHost()
Gets host name used by the request.
public
stdClass|array|bool
getJsonRawBody( bool $associative = false )
Gets decoded JSON HTTP raw request body
public
array
getLanguages()
Gets languages array and their quality accepted by the browser/client
public
string
getMethod()
Gets HTTP method which request has been made
public
int
getPort()
Gets information about the port on which the request is made
public
mixed
getPost(string $name = null,mixed $filters = null,mixed $defaultValue = null,bool $notAllowEmpty = false,bool $noRecursive = false)
Gets a variable from the $_POST superglobal applying filters if needed
public
mixed
getPut(string $name = null,mixed $filters = null,mixed $defaultValue = null,bool $notAllowEmpty = false,bool $noRecursive = false)
Gets a variable from the PUT request
public
mixed
getQuery(string $name = null,mixed $filters = null,mixed $defaultValue = null,bool $notAllowEmpty = false,bool $noRecursive = false)
Gets variable from $_GET superglobal applying filters if needed
public
string
getRawBody()
Gets HTTP raw request body
public
string
getScheme()
Gets HTTP schema (http/https)
public
string|null
getServer( string $name )
Gets variable from $_SERVER superglobal
public
string
getServerAddress()
Gets active server address IP
public
string
getServerName()
Gets active server name
public
string
getURI( bool $onlyPath = false )
Gets HTTP URI which request has been made to
public
FileInterface[]
getUploadedFiles(bool $onlySuccessful = false,bool $namedKeys = false)
Gets attached files as Phalcon\Http\Request\FileInterface compatible
public
string
getUserAgent()
Gets HTTP user agent used to made the request
public
bool
has( string $name )
Checks whether $_REQUEST superglobal has certain index
public
bool
hasFiles()
Checks whether request include attached files
public
bool
hasHeader( string $header )
Checks whether headers has certain index
public
bool
hasPost( string $name )
Checks whether $_POST superglobal has certain index
public
bool
hasPut( string $name )
Checks whether the PUT data has certain index
public
bool
hasQuery( string $name )
Checks whether $_GET superglobal has certain index
public
bool
hasServer( string $name )
Checks whether $_SERVER superglobal has certain index
public
bool
isAjax()
Checks whether request has been made using ajax. Checks if $_SERVER["HTTP_X_REQUESTED_WITH"] === "XMLHttpRequest"
public
bool
isConnect()
Checks whether HTTP method is CONNECT. if $_SERVER["REQUEST_METHOD"] === "CONNECT"
public
bool
isDelete()
Checks whether HTTP method is DELETE. if $_SERVER["REQUEST_METHOD"] === "DELETE"
public
bool
isGet()
Checks whether HTTP method is GET. if $_SERVER["REQUEST_METHOD"] === "GET"
public
bool
isHead()
Checks whether HTTP method is HEAD. if $_SERVER["REQUEST_METHOD"] === "HEAD"
public
bool
isMethod(mixed $methods,bool $strict = false)
Check if HTTP method match any of the passed methods
public
bool
isOptions()
Checks whether HTTP method is OPTIONS. if $_SERVER["REQUEST_METHOD"] === "OPTIONS"
public
bool
isPost()
Checks whether HTTP method is POST. if $_SERVER["REQUEST_METHOD"] === "POST"
public
bool
isPurge()
Checks whether HTTP method is PURGE (Squid and Varnish support). if $_SERVER["REQUEST_METHOD"] === "PURGE"
public
bool
isPut()
Checks whether HTTP method is PUT. if $_SERVER["REQUEST_METHOD"] === "PUT"
public
bool
isSecure()
Checks whether request has been made using any secure layer
public
bool
isSoap()
Checks whether request has been made using SOAP
public
bool
isTrace()
Checks whether HTTP method is TRACE.
public
int
numFiles( bool $onlySuccessful = false )
Returns the number of files available
Methods¶
get()¶
public function get(
string $name = null,
mixed $filters = null,
mixed $defaultValue = null,
bool $notAllowEmpty = false,
bool $noRecursive = false
): mixed;
Gets a variable from the $_REQUEST superglobal applying filters if needed. If no parameters are given the $_REQUEST superglobal is returned
// Returns value from $_REQUEST["user_email"] without sanitizing
$userEmail = $request->get("user_email");
// Returns value from $_REQUEST["user_email"] with sanitizing
$userEmail = $request->get("user_email", "email");
getAcceptableContent()¶
Gets an array with mime/types and their quality accepted by the browser/client from _SERVER["HTTP_ACCEPT"]
getBasicAuth()¶
Gets auth info accepted by the browser/client from $_SERVER["PHP_AUTH_USER"]
getBestAccept()¶
Gets best mime/type accepted by the browser/client from _SERVER["HTTP_ACCEPT"]
getBestCharset()¶
Gets best charset accepted by the browser/client from _SERVER["HTTP_ACCEPT_CHARSET"]
getBestLanguage()¶
Gets best language accepted by the browser/client from _SERVER["HTTP_ACCEPT_LANGUAGE"]
getClientAddress()¶
Gets most possible client IPv4 Address. This method searches in $_SERVER["REMOTE_ADDR"] and optionally in $_SERVER["HTTP_X_FORWARDED_FOR"]
getClientCharsets()¶
Gets a charsets array and their quality accepted by the browser/client from _SERVER["HTTP_ACCEPT_CHARSET"]
getContentType()¶
Gets content type which request has been made
getDigestAuth()¶
Gets auth info accepted by the browser/client from $_SERVER["PHP_AUTH_DIGEST"]
getHTTPReferer()¶
Gets web page that refers active request. ie: http://www.google.com
getHeader()¶
Gets HTTP header from request data
getHeaders()¶
Returns the available headers in the request
$_SERVER = [
"PHP_AUTH_USER" => "phalcon",
"PHP_AUTH_PW" => "secret",
];
$headers = $request->getHeaders();
echo $headers["Authorization"]; // Basic cGhhbGNvbjpzZWNyZXQ=
getHttpHost()¶
Gets host name used by the request.
Request::getHttpHost trying to find host name in following order:
$_SERVER["HTTP_HOST"]$_SERVER["SERVER_NAME"]$_SERVER["SERVER_ADDR"]
Optionally Request::getHttpHost validates and clean host name.
The Request::$_strictHostCheck can be used to validate host name.
Note: validation and cleaning have a negative performance impact because they use regular expressions.
use Phalcon\Http\Request;
$request = new Request;
$_SERVER["HTTP_HOST"] = "example.com";
$request->getHttpHost(); // example.com
$_SERVER["HTTP_HOST"] = "example.com:8080";
$request->getHttpHost(); // example.com:8080
$request->setStrictHostCheck(true);
$_SERVER["HTTP_HOST"] = "ex=am~ple.com";
$request->getHttpHost(); // UnexpectedValueException
$_SERVER["HTTP_HOST"] = "ExAmPlE.com";
$request->getHttpHost(); // example.com
getJsonRawBody()¶
Gets decoded JSON HTTP raw request body
getLanguages()¶
Gets languages array and their quality accepted by the browser/client from _SERVER["HTTP_ACCEPT_LANGUAGE"]
getMethod()¶
Gets HTTP method which request has been made
If the X-HTTP-Method-Override header is set, and if the method is a POST, then it is used to determine the "real" intended HTTP method.
The _method request parameter can also be used to determine the HTTP method, but only if setHttpMethodParameterOverride(true) has been called.
The method is always an uppercased string.
getPort()¶
Gets information about the port on which the request is made
getPost()¶
public function getPost(
string $name = null,
mixed $filters = null,
mixed $defaultValue = null,
bool $notAllowEmpty = false,
bool $noRecursive = false
): mixed;
Gets a variable from the $_POST superglobal applying filters if needed If no parameters are given the $_POST superglobal is returned
// Returns value from $_POST["user_email"] without sanitizing
$userEmail = $request->getPost("user_email");
// Returns value from $_POST["user_email"] with sanitizing
$userEmail = $request->getPost("user_email", "email");
getPut()¶
public function getPut(
string $name = null,
mixed $filters = null,
mixed $defaultValue = null,
bool $notAllowEmpty = false,
bool $noRecursive = false
): mixed;
Gets a variable from the PUT request
// Returns value from PUT stream without sanitizing
$userEmail = $request->getPut("user_email");
// Returns value from PUT stream with sanitizing
$userEmail = $request->getPut("user_email", "email");
getQuery()¶
public function getQuery(
string $name = null,
mixed $filters = null,
mixed $defaultValue = null,
bool $notAllowEmpty = false,
bool $noRecursive = false
): mixed;
Gets variable from $_GET superglobal applying filters if needed If no parameters are given the $_GET superglobal is returned
// Returns value from $_GET["id"] without sanitizing
$id = $request->getQuery("id");
// Returns value from $_GET["id"] with sanitizing
$id = $request->getQuery("id", "int");
// Returns value from $_GET["id"] with a default value
$id = $request->getQuery("id", null, 150);
getRawBody()¶
Gets HTTP raw request body
getScheme()¶
Gets HTTP schema (http/https)
getServer()¶
Gets variable from $_SERVER superglobal
getServerAddress()¶
Gets active server address IP
getServerName()¶
Gets active server name
getURI()¶
Gets HTTP URI which request has been made to
// Returns /some/path?with=queryParams
$uri = $request->getURI();
// Returns /some/path
$uri = $request->getURI(true);
getUploadedFiles()¶
public function getUploadedFiles(
bool $onlySuccessful = false,
bool $namedKeys = false
): FileInterface[];
Gets attached files as Phalcon\Http\Request\FileInterface compatible instances
getUserAgent()¶
Gets HTTP user agent used to made the request
has()¶
Checks whether $_REQUEST superglobal has certain index
hasFiles()¶
Checks whether request include attached files
hasHeader()¶
Checks whether headers has certain index
hasPost()¶
Checks whether $_POST superglobal has certain index
hasPut()¶
Checks whether the PUT data has certain index
hasQuery()¶
Checks whether $_GET superglobal has certain index
hasServer()¶
Checks whether $_SERVER superglobal has certain index
isAjax()¶
Checks whether request has been made using ajax. Checks if $_SERVER["HTTP_X_REQUESTED_WITH"] === "XMLHttpRequest"
isConnect()¶
Checks whether HTTP method is CONNECT. if $_SERVER["REQUEST_METHOD"] === "CONNECT"
isDelete()¶
Checks whether HTTP method is DELETE. if $_SERVER["REQUEST_METHOD"] === "DELETE"
isGet()¶
Checks whether HTTP method is GET. if $_SERVER["REQUEST_METHOD"] === "GET"
isHead()¶
Checks whether HTTP method is HEAD. if $_SERVER["REQUEST_METHOD"] === "HEAD"
isMethod()¶
Check if HTTP method match any of the passed methods
isOptions()¶
Checks whether HTTP method is OPTIONS. if $_SERVER["REQUEST_METHOD"] === "OPTIONS"
isPost()¶
Checks whether HTTP method is POST. if $_SERVER["REQUEST_METHOD"] === "POST"
isPurge()¶
Checks whether HTTP method is PURGE (Squid and Varnish support). if $_SERVER["REQUEST_METHOD"] === "PURGE"
isPut()¶
Checks whether HTTP method is PUT. if $_SERVER["REQUEST_METHOD"] === "PUT"
isSecure()¶
Checks whether request has been made using any secure layer
isSoap()¶
Checks whether request has been made using SOAP
isTrace()¶
Checks whether HTTP method is TRACE. if $_SERVER["REQUEST_METHOD"] === "TRACE"
numFiles()¶
Returns the number of files available
Http\Request\Exception¶
Class Source on GitHub
Phalcon\Http\Request\Exception
Exceptions thrown in Phalcon\Http\Request will use this class
Http\Request\Exceptions\FilterServiceUnavailable¶
Class Source on GitHub
\ExceptionPhalcon\Http\Request\ExceptionPhalcon\Http\Request\Exceptions\FilterServiceUnavailable
Uses Phalcon\Http\Request\Exception
Method Summary¶
Methods¶
__construct()¶
Http\Request\Exceptions\InvalidHost¶
Class Source on GitHub
UnexpectedValueExceptionPhalcon\Http\Request\Exceptions\InvalidHost
Uses UnexpectedValueException
Method Summary¶
Methods¶
__construct()¶
Http\Request\Exceptions\InvalidHttpMethod¶
Class Source on GitHub
\ExceptionPhalcon\Http\Request\ExceptionPhalcon\Http\Request\Exceptions\InvalidHttpMethod
Uses Phalcon\Http\Request\Exception
Method Summary¶
Methods¶
__construct()¶
Http\Request\Exceptions\MissingFilters¶
Class Source on GitHub
\ExceptionPhalcon\Http\Request\ExceptionPhalcon\Http\Request\Exceptions\MissingFilters
Uses Phalcon\Http\Request\Exception
Method Summary¶
Methods¶
__construct()¶
Http\Request\Exceptions\SanitizerNotFound¶
Class Source on GitHub
\ExceptionPhalcon\Http\Request\ExceptionPhalcon\Http\Request\Exceptions\SanitizerNotFound
Uses Phalcon\Http\Request\Exception
Method Summary¶
Methods¶
__construct()¶
Http\Request\File¶
Class Source on GitHub
Phalcon\Http\Request\File
Provides OO wrappers to the $_FILES superglobal
use Phalcon\Mvc\Controller;
class PostsController extends Controller
{
public function uploadAction()
{
// Check if the user has uploaded files
if ($this->request->hasFiles() == true) {
// Print the real file names and their sizes
foreach ($this->request->getUploadedFiles() as $file) {
echo $file->getName(), " ", $file->getSize(), "\n";
}
}
}
}
Phalcon\Http\Request\File- implementsPhalcon\Http\Request\FileInterface
Method Summary¶
public
__construct(array $file,string $key = "")
Phalcon\Http\Request\File constructor
public
int
getError()
public
string
getExtension()
public
string
getKey()
public
string
getName()
Returns the real name of the uploaded file
public
string
getRealType()
Gets the real mime type of the upload file using finfo
public
int
getSize()
Returns the file size of the uploaded file
public
string
getTempName()
Returns the temporary name of the uploaded file
public
string
getType()
Returns the mime type reported by the browser
public
bool
isUploadedFile()
Checks whether the file has been uploaded via Post.
public
bool
moveTo( string $destination )
Moves the temporary file to a destination within the application
Properties¶
protected
int
$error = 0
protected
string
$extension = ""
protected
string
$key = ""
protected
string
$name = ""
protected
string
$realType
protected
int
$size = 0
protected
string
$tmpName = ""
protected
string
$type = ""
Methods¶
__construct()¶
Phalcon\Http\Request\File constructor
getError()¶
getExtension()¶
getKey()¶
getName()¶
Returns the real name of the uploaded file
getRealType()¶
Gets the real mime type of the upload file using finfo
getSize()¶
Returns the file size of the uploaded file
getTempName()¶
Returns the temporary name of the uploaded file
getType()¶
Returns the mime type reported by the browser This mime type is not completely secure, use getRealType() instead
isUploadedFile()¶
Checks whether the file has been uploaded via Post.
moveTo()¶
Moves the temporary file to a destination within the application
Http\Request\FileInterface¶
Interface Source on GitHub
Interface for Phalcon\Http\Request\File
Phalcon\Http\Request\FileInterface
Method Summary¶
public
int
getError()
Returns the error if any
public
string
getName()
Returns the real name of the uploaded file
public
string
getRealType()
Gets the real mime type of the upload file using finfo
public
int
getSize()
Returns the file size of the uploaded file
public
string
getTempName()
Returns the temporal name of the uploaded file
public
string
getType()
Returns the mime type reported by the browser
public
bool
moveTo( string $destination )
Move the temporary file to a destination
Methods¶
getError()¶
Returns the error if any
getName()¶
Returns the real name of the uploaded file
getRealType()¶
Gets the real mime type of the upload file using finfo
getSize()¶
Returns the file size of the uploaded file
getTempName()¶
Returns the temporal name of the uploaded file
getType()¶
Returns the mime type reported by the browser This mime type is not completely secure, use getRealType() instead
moveTo()¶
Move the temporary file to a destination
Http\Response¶
Class Source on GitHub
Part of the HTTP cycle is return responses to the clients. Phalcon\HTTP\Response is the Phalcon component responsible to achieve this task. HTTP responses are usually composed by headers and body.
$response = new \Phalcon\Http\Response();
$response->setStatusCode(200, "OK");
$response->setContent("<html><body>Hello</body></html>");
$response->send();
Phalcon\Http\Response- implementsPhalcon\Http\ResponseInterface,Phalcon\Di\InjectionAwareInterface,Phalcon\Events\EventsAwareInterface,Phalcon\Http\Message\ResponseStatusCodeInterface
Uses DateTime · DateTimeZone · Phalcon\Di\Di · Phalcon\Di\DiInterface · Phalcon\Di\InjectionAwareInterface · Phalcon\Events\EventsAwareInterface · Phalcon\Events\ManagerInterface · Phalcon\Http\Message\ResponseStatusCodeInterface · Phalcon\Http\Response\CookiesInterface · Phalcon\Http\Response\Exceptions\NonStandardStatusCodeRequiresMessage · Phalcon\Http\Response\Exceptions\ResponseAlreadySent · Phalcon\Http\Response\Exceptions\UrlServiceUnavailable · Phalcon\Http\Response\Headers · Phalcon\Http\Response\HeadersInterface · Phalcon\Mvc\Url\UrlInterface · Phalcon\Mvc\ViewInterface · Phalcon\Support\Helper\File\Basename · Phalcon\Support\Helper\Json\Encode
Method Summary¶
public
__construct(string $content = null,mixed $code = null,mixed $status = null)
Phalcon\Http\Response constructor
public
ResponseInterface
appendContent( mixed $content )
Appends a string to the HTTP response body
public
string
getContent()
Gets the HTTP response body
public
CookiesInterface
getCookies()
Returns cookies set by the user
public
DiInterface
getDI()
Returns the internal dependency injector
public
ManagerInterface|null
getEventsManager()
Returns the internal event manager
public
HeadersInterface
getHeaders()
Returns headers set by the user
public
string|null
getReasonPhrase()
Returns the reason phrase
public
int|null
getStatusCode()
Returns the status code
public
bool
hasHeader( string $name )
Checks if a header exists
public
bool
isSent()
Check if the response is already sent
public
ResponseInterface
redirect(mixed $location = null,bool $externalRedirect = false,int $statusCode = 302)
Redirect by HTTP to another action or URL
public
ResponseInterface
removeHeader( string $name )
Remove a header in the response
public
ResponseInterface
resetHeaders()
Resets all the established headers
public
ResponseInterface
send()
Prints out HTTP response to the client
public
ResponseInterface
sendCookies()
Sends cookies to the client
public
ResponseInterface|bool
sendHeaders()
Sends headers to the client
public
ResponseInterface
setCache( int $minutes )
Sets Cache headers to use HTTP cache
public
ResponseInterface
setContent( string $content )
Sets HTTP response body
public
ResponseInterface
setContentLength( int $contentLength )
Sets the response content-length
public
ResponseInterface
setContentType(string $contentType,mixed $charset = null)
Sets the response content-type mime, optionally the charset
public
ResponseInterface
setCookies( CookiesInterface $cookies )
Sets a cookies bag for the response externally
public
void
setDI( DiInterface $container )
Sets the dependency injector
public
ResponseInterface
setEtag( string $etag )
Set a custom ETag
public
void
setEventsManager( ManagerInterface $eventsManager )
Sets the events manager
public
ResponseInterface
setExpires( DateTime $datetime )
Sets an Expires header in the response that allows to use the HTTP cache
public
ResponseInterface
setFileToSend(string $filePath,mixed $attachmentName = null,mixed $attachment = true)
Sets an attached file to be sent at the end of the request
public
ResponseInterface
setHeader(string $name,mixed $value)
Overwrites a header in the response
public
ResponseInterface
setHeaders( HeadersInterface $headers )
Sets a headers bag for the response externally
public
ResponseInterface
setJsonContent(mixed $content,int $jsonOptions = 0,int $depth = 512)
Sets HTTP response body. The parameter is automatically converted to JSON
public
ResponseInterface
setLastModified( DateTime $datetime )
Sets Last-Modified header
public
ResponseInterface
setNotModified()
Sends a Not-Modified response
public
ResponseInterface
setRawHeader( string $header )
Send a raw header to the response
public
ResponseInterface
setStatusCode(int $code,string $message = null)
Sets the HTTP response code
Properties¶
protected
DiInterface|null
$container = null
protected
string|null
$content = null
protected
CookiesInterface|null
$cookies = null
protected
Encode
$encode
protected
ManagerInterface|null
$eventsManager = null
protected
string|null
$file = null
protected
Headers
$headers
protected
bool
$sent = false
Methods¶
__construct()¶
Phalcon\Http\Response constructor
appendContent()¶
Appends a string to the HTTP response body
getContent()¶
Gets the HTTP response body
getCookies()¶
Returns cookies set by the user
getDI()¶
Returns the internal dependency injector
getEventsManager()¶
Returns the internal event manager
getHeaders()¶
Returns headers set by the user
getReasonPhrase()¶
Returns the reason phrase
getStatusCode()¶
Returns the status code
hasHeader()¶
Checks if a header exists
isSent()¶
Check if the response is already sent
redirect()¶
public function redirect(
mixed $location = null,
bool $externalRedirect = false,
int $statusCode = 302
): ResponseInterface;
Redirect by HTTP to another action or URL
// Using a string redirect (internal/external)
$response->redirect("posts/index");
$response->redirect("http://en.wikipedia.org", true);
$response->redirect("http://www.example.com/new-location", true, 301);
// Making a redirection based on a named route
$response->redirect(
[
"for" => "index-lang",
"lang" => "jp",
"controller" => "index",
]
);
removeHeader()¶
Remove a header in the response
resetHeaders()¶
Resets all the established headers
send()¶
Prints out HTTP response to the client
sendCookies()¶
Sends cookies to the client
sendHeaders()¶
Sends headers to the client
setCache()¶
Sets Cache headers to use HTTP cache
setContent()¶
Sets HTTP response body
setContentLength()¶
Sets the response content-length
setContentType()¶
Sets the response content-type mime, optionally the charset
setCookies()¶
Sets a cookies bag for the response externally
setDI()¶
Sets the dependency injector
setEtag()¶
Set a custom ETag
setEventsManager()¶
Sets the events manager
setExpires()¶
Sets an Expires header in the response that allows to use the HTTP cache
setFileToSend()¶
public function setFileToSend(
string $filePath,
mixed $attachmentName = null,
mixed $attachment = true
): ResponseInterface;
Sets an attached file to be sent at the end of the request
setHeader()¶
Overwrites a header in the response
setHeaders()¶
Sets a headers bag for the response externally
setJsonContent()¶
public function setJsonContent(
mixed $content,
int $jsonOptions = 0,
int $depth = 512
): ResponseInterface;
Sets HTTP response body. The parameter is automatically converted to JSON and also sets default header: Content-Type: "application/json; charset=UTF-8"
setLastModified()¶
Sets Last-Modified header
setNotModified()¶
Sends a Not-Modified response
setRawHeader()¶
Send a raw header to the response
setStatusCode()¶
Sets the HTTP response code
Http\ResponseInterface¶
Interface Source on GitHub
Phalcon\Http\Response
Interface for Phalcon\Http\Response
Phalcon\Http\ResponseInterface
Uses DateTime · Phalcon\Http\Response\HeadersInterface
Method Summary¶
public
ResponseInterface
appendContent( string $content )
Appends a string to the HTTP response body
public
string
getContent()
Gets the HTTP response body
public
HeadersInterface
getHeaders()
Returns headers set by the user
public
int|null
getStatusCode()
Returns the status code
public
bool
hasHeader( string $name )
Checks if a header exists
public
bool
isSent()
Checks if the response was already sent
public
ResponseInterface
redirect(string $location = null,bool $externalRedirect = false,int $statusCode = 302)
Redirect by HTTP to another action or URL
public
ResponseInterface
resetHeaders()
Resets all the established headers
public
ResponseInterface
send()
Prints out HTTP response to the client
public
ResponseInterface
sendCookies()
Sends cookies to the client
public
ResponseInterface|bool
sendHeaders()
Sends headers to the client
public
ResponseInterface
setContent( string $content )
Sets HTTP response body
public
ResponseInterface
setContentLength( int $contentLength )
Sets the response content-length
public
ResponseInterface
setContentType(string $contentType,string $charset = null)
Sets the response content-type mime, optionally the charset
public
ResponseInterface
setExpires( DateTime $datetime )
Sets output expire time header
public
ResponseInterface
setFileToSend(string $filePath,string $attachmentName = null)
Sets an attached file to be sent at the end of the request
public
ResponseInterface
setHeader(string $name,string $value)
Overwrites a header in the response
public
ResponseInterface
setJsonContent( mixed $content )
Sets HTTP response body. The parameter is automatically converted to JSON
public
ResponseInterface
setNotModified()
Sends a Not-Modified response
public
ResponseInterface
setRawHeader( string $header )
Send a raw header to the response
public
ResponseInterface
setStatusCode(int $code,string $message = null)
Sets the HTTP response code
Methods¶
appendContent()¶
Appends a string to the HTTP response body
getContent()¶
Gets the HTTP response body
getHeaders()¶
Returns headers set by the user
getStatusCode()¶
Returns the status code
hasHeader()¶
Checks if a header exists
isSent()¶
Checks if the response was already sent
redirect()¶
public function redirect(
string $location = null,
bool $externalRedirect = false,
int $statusCode = 302
): ResponseInterface;
Redirect by HTTP to another action or URL
resetHeaders()¶
Resets all the established headers
send()¶
Prints out HTTP response to the client
sendCookies()¶
Sends cookies to the client
sendHeaders()¶
Sends headers to the client
setContent()¶
Sets HTTP response body
setContentLength()¶
Sets the response content-length
setContentType()¶
Sets the response content-type mime, optionally the charset
setExpires()¶
Sets output expire time header
setFileToSend()¶
public function setFileToSend(
string $filePath,
string $attachmentName = null
): ResponseInterface;
Sets an attached file to be sent at the end of the request
setHeader()¶
Overwrites a header in the response
setJsonContent()¶
Sets HTTP response body. The parameter is automatically converted to JSON
setNotModified()¶
Sends a Not-Modified response
setRawHeader()¶
Send a raw header to the response
setStatusCode()¶
Sets the HTTP response code
Http\Response\Cookies¶
Class Source on GitHub
This class is a bag to manage the cookies.
A cookies bag is automatically registered as part of the 'response' service
in the DI. By default, cookies are automatically encrypted before being sent
to the client and are decrypted when retrieved from the user. To set sign key
used to generate a message authentication code use
Phalcon\Http\Response\Cookies::setSignKey().
use Phalcon\Di\Di;
use Phalcon\Encryption\Crypt;
use Phalcon\Http\Response\Cookies;
$di = new Di();
$di->set(
'crypt',
function () {
$crypt = new Crypt();
// The `$key' should have been previously generated in a cryptographically safe way.
$key = "T4\xb1\x8d\xa9\x98\x05\\\x8c\xbe\x1d\x07&[\x99\x18\xa4~Lc1\xbeW\xb3";
$crypt->setKey($key);
return $crypt;
}
);
$di->set(
'cookies',
function () {
$cookies = new Cookies();
// The `$key' MUST be at least 32 characters long and generated using a
// cryptographically secure pseudo random generator.
$key = "#1dj8$=dp?.ak//j1V$~%*0XaK\xb1\x8d\xa9\x98\x054t7w!z%C*F-Jk\x98\x05\\\x5c";
$cookies->setSignKey($key);
return $cookies;
}
);
stdClassPhalcon\Di\AbstractInjectionAwarePhalcon\Http\Response\Cookies- implementsPhalcon\Http\Response\CookiesInterface
Uses Phalcon\Di\AbstractInjectionAware · Phalcon\Di\DiInterface · Phalcon\Http\Cookie\CookieInterface · Phalcon\Http\Cookie\Exception · Phalcon\Http\Response\Exceptions\ResponseServiceUnavailable
Method Summary¶
public
__construct(bool $useEncryption = true,string $signKey = null)
Phalcon\Http\Response\Cookies constructor
public
bool
delete( string $name )
Deletes a cookie by its name
public
CookieInterface
get( string $name )
Gets a cookie from the bag
public
array
getCookies()
Gets all cookies from the bag
public
bool
has( string $name )
Check if a cookie is defined in the bag or exists in the _COOKIE
public
bool
isSent()
Returns if the headers have already been sent
public
bool
isUsingEncryption()
Returns if the bag is automatically encrypting/decrypting cookies
public
CookiesInterface
reset()
Reset set cookies
public
bool
send()
Sends the cookies to the client
public
CookiesInterface
set(string $name,mixed $value = null,int $expire = 0,string $path = "/",bool $secure = false,string $domain = "",bool $httpOnly = false,array $options = [])
Sets a cookie to be sent at the end of the request.
public
CookiesInterface
setSignKey( string $signKey = null )
Sets the cookie's sign key.
public
CookiesInterface
useEncryption( bool $useEncryption )
Set if cookies in the bag must be automatically encrypted/decrypted
Properties¶
protected
array
$cookies = []
protected
bool
$isRegistered = false
protected
bool
$isSent = false
protected
string|null
$signKey = null
The cookie's sign key.
protected
bool
$useEncryption = true
Methods¶
__construct()¶
Phalcon\Http\Response\Cookies constructor
delete()¶
Deletes a cookie by its name This method does not removes cookies from the _COOKIE superglobal
get()¶
Gets a cookie from the bag
getCookies()¶
Gets all cookies from the bag
has()¶
Check if a cookie is defined in the bag or exists in the _COOKIE superglobal
isSent()¶
Returns if the headers have already been sent
isUsingEncryption()¶
Returns if the bag is automatically encrypting/decrypting cookies
reset()¶
Reset set cookies
send()¶
Sends the cookies to the client Cookies aren't sent if headers are sent in the current request
set()¶
public function set(
string $name,
mixed $value = null,
int $expire = 0,
string $path = "/",
bool $secure = false,
string $domain = "",
bool $httpOnly = false,
array $options = []
): CookiesInterface;
Sets a cookie to be sent at the end of the request.
This method overrides any cookie set before with the same name.
use Phalcon\Http\Response\Cookies;
$now = new DateTimeImmutable();
$tomorrow = $now->modify('tomorrow');
$cookies = new Cookies();
$cookies->set(
'remember-me',
json_encode(['user_id' => 1]),
(int) $tomorrow->format('U'),
);
setSignKey()¶
Sets the cookie's sign key.
The `$signKey' MUST be at least 32 characters long and generated using a cryptographically secure pseudo random generator.
Use NULL to disable cookie signing.
@see \Phalcon\Security\Random
useEncryption()¶
Set if cookies in the bag must be automatically encrypted/decrypted
Http\Response\CookiesInterface¶
Interface Source on GitHub
Interface for Phalcon\Http\Response\Cookies
Phalcon\Http\Response\CookiesInterface
Uses Phalcon\Http\Cookie\CookieInterface
Method Summary¶
public
bool
delete( string $name )
Deletes a cookie by its name
public
CookieInterface
get( string $name )
Gets a cookie from the bag
public
bool
has( string $name )
Check if a cookie is defined in the bag or exists in the _COOKIE superglobal
public
bool
isUsingEncryption()
Returns if the bag is automatically encrypting/decrypting cookies
public
CookiesInterface
reset()
Reset set cookies
public
bool
send()
Sends the cookies to the client
public
CookiesInterface
set(string $name,mixed $value = null,int $expire = 0,string $path = "/",bool $secure = false,string $domain = "",bool $httpOnly = false,array $options = [])
Sets a cookie to be sent at the end of the request
public
CookiesInterface
useEncryption( bool $useEncryption )
Set if cookies in the bag must be automatically encrypted/decrypted
Methods¶
delete()¶
Deletes a cookie by its name This method does not removes cookies from the _COOKIE superglobal
get()¶
Gets a cookie from the bag
has()¶
Check if a cookie is defined in the bag or exists in the _COOKIE superglobal
isUsingEncryption()¶
Returns if the bag is automatically encrypting/decrypting cookies
reset()¶
Reset set cookies
send()¶
Sends the cookies to the client
set()¶
public function set(
string $name,
mixed $value = null,
int $expire = 0,
string $path = "/",
bool $secure = false,
string $domain = "",
bool $httpOnly = false,
array $options = []
): CookiesInterface;
Sets a cookie to be sent at the end of the request
useEncryption()¶
Set if cookies in the bag must be automatically encrypted/decrypted
Http\Response\Exception¶
Class Source on GitHub
Phalcon\Http\Response\Exception
Exceptions thrown in Phalcon\Http\Response will use this class.
Http\Response\Exceptions\NonStandardStatusCodeRequiresMessage¶
Class Source on GitHub
\ExceptionPhalcon\Http\Response\ExceptionPhalcon\Http\Response\Exceptions\NonStandardStatusCodeRequiresMessage
Uses Phalcon\Http\Response\Exception
Method Summary¶
Methods¶
__construct()¶
Http\Response\Exceptions\ResponseAlreadySent¶
Class Source on GitHub
\ExceptionPhalcon\Http\Response\ExceptionPhalcon\Http\Response\Exceptions\ResponseAlreadySent
Uses Phalcon\Http\Response\Exception
Method Summary¶
Methods¶
__construct()¶
Http\Response\Exceptions\ResponseServiceUnavailable¶
Class Source on GitHub
\ExceptionPhalcon\Http\Response\ExceptionPhalcon\Http\Response\Exceptions\ResponseServiceUnavailable
Uses Phalcon\Http\Response\Exception
Method Summary¶
Methods¶
__construct()¶
Http\Response\Exceptions\UrlServiceUnavailable¶
Class Source on GitHub
\ExceptionPhalcon\Http\Response\ExceptionPhalcon\Http\Response\Exceptions\UrlServiceUnavailable
Uses Phalcon\Http\Response\Exception
Method Summary¶
Methods¶
__construct()¶
Http\Response\Headers¶
Class Source on GitHub
This class is a bag to manage the response headers
Phalcon\Http\Response\Headers- implementsPhalcon\Http\Response\HeadersInterface,IteratorAggregate
Uses IteratorAggregate · Traversable
Method Summary¶
public
string|bool|null
get( string $name )
Gets a header value from the internal bag
public
Traversable
getIterator()
public
bool
has( string $name )
Checks if a header exists
public
bool
isSent()
Returns if the headers have already been sent
public
HeadersInterface
remove( string $header )
Removes a header by its name
public
void
reset()
Reset set headers
public
bool
send()
Sends the headers to the client
public
HeadersInterface
set(string $name,string $value)
Sets a header to be sent at the end of the request
public
HeadersInterface
setRaw( string $header )
Sets a raw header to be sent at the end of the request
public
array
toArray()
Returns the current headers as an array
Properties¶
protected
array
$headers = []
protected
bool
$isSent = false
Methods¶
get()¶
Gets a header value from the internal bag
getIterator()¶
has()¶
Checks if a header exists
isSent()¶
Returns if the headers have already been sent
remove()¶
Removes a header by its name
reset()¶
Reset set headers
send()¶
Sends the headers to the client
set()¶
Sets a header to be sent at the end of the request
setRaw()¶
Sets a raw header to be sent at the end of the request
toArray()¶
Returns the current headers as an array
Http\Response\HeadersInterface¶
Interface Source on GitHub
Interface for Phalcon\Http\Response\Headers compatible bags
Phalcon\Http\Response\HeadersInterface
Method Summary¶
public
string|bool|null
get( string $name )
Gets a header value from the internal bag
public
bool
has( string $name )
Checks if a header exists
public
void
reset()
Reset set headers
public
bool
send()
Sends the headers to the client
public
HeadersInterface
set(string $name,string $value)
Sets a header to be sent at the end of the request
public
HeadersInterface
setRaw( string $header )
Sets a raw header to be sent at the end of the request
Methods¶
get()¶
Gets a header value from the internal bag
has()¶
Checks if a header exists
reset()¶
Reset set headers
send()¶
Sends the headers to the client
set()¶
Sets a header to be sent at the end of the request
setRaw()¶
Sets a raw header to be sent at the end of the request