/var/www/vhosts/ihelp.ro/httpdocs/vendor/cakephp/cakephp/src/Http
NameSizeModeActions
Client/-0755rm
Cookie/-0755rm
Exception/-0755rm
Middleware/-0755rm
Session/-0755rm
TestSuite/-0755rm
BaseApplication.php93880644editdlrm
CallbackStream.php15750644editdlrm
Client.php256240644editdlrm
composer.json15090644editdlrm
ContentTypeNegotiation.php52730644editdlrm
ControllerFactory.php2300644editdlrm
ControllerFactoryInterface.php15340644editdlrm
CorsBuilder.php60250644editdlrm
FlashMessage.php68120644editdlrm
LICENSE.txt12040644editdlrm
MiddlewareApplication.php17910644editdlrm
MiddlewareQueue.php91130644editdlrm
README.md33920644editdlrm
Response.php512180644editdlrm
ResponseEmitter.php89400644editdlrm
Runner.php30640644editdlrm
Server.php55520644editdlrm
ServerRequest.php559690644editdlrm
ServerRequestFactory.php130810644editdlrm
Session.php209880644editdlrm
Uri.php50270644editdlrm
Edit: /var/www/vhosts/ihelp.ro/httpdocs/vendor/cakephp/cakephp/src/Http/CorsBuilder.php (6025B)
*/ protected $_headers = []; /** * Constructor. * * @param \Psr\Http\Message\MessageInterface $response The response object to add headers onto. * @param string $origin The request's Origin header. * @param bool $isSsl Whether the request was over SSL. */ public function __construct(MessageInterface $response, string $origin, bool $isSsl = false) { $this->_origin = $origin; $this->_isSsl = $isSsl; $this->_response = $response; } /** * Apply the queued headers to the response. * * If the builder has no Origin, or if there are no allowed domains, * or if the allowed domains do not match the Origin header no headers will be applied. * * @return \Psr\Http\Message\MessageInterface A new instance of the response with new headers. */ public function build(): MessageInterface { $response = $this->_response; if (empty($this->_origin)) { return $response; } if (isset($this->_headers['Access-Control-Allow-Origin'])) { foreach ($this->_headers as $key => $value) { $response = $response->withHeader($key, $value); } } return $response; } /** * Set the list of allowed domains. * * Accepts a string or an array of domains that have CORS enabled. * You can use `*.example.com` wildcards to accept subdomains, or `*` to allow all domains * * @param array|string $domains The allowed domains * @return $this */ public function allowOrigin($domains) { $allowed = $this->_normalizeDomains((array)$domains); foreach ($allowed as $domain) { if (!preg_match($domain['preg'], $this->_origin)) { continue; } $value = $domain['original'] === '*' ? '*' : $this->_origin; $this->_headers['Access-Control-Allow-Origin'] = $value; break; } return $this; } /** * Normalize the origin to regular expressions and put in an array format * * @param array $domains Domain names to normalize. * @return array */ protected function _normalizeDomains(array $domains): array { $result = []; foreach ($domains as $domain) { if ($domain === '*') { $result[] = ['preg' => '@.@', 'original' => '*']; continue; } $original = $preg = $domain; if (strpos($domain, '://') === false) { $preg = ($this->_isSsl ? 'https://' : 'http://') . $domain; } $preg = '@^' . str_replace('\*', '.*', preg_quote($preg, '@')) . '$@'; $result[] = compact('original', 'preg'); } return $result; } /** * Set the list of allowed HTTP Methods. * * @param array $methods The allowed HTTP methods * @return $this */ public function allowMethods(array $methods) { $this->_headers['Access-Control-Allow-Methods'] = implode(', ', $methods); return $this; } /** * Enable cookies to be sent in CORS requests. * * @return $this */ public function allowCredentials() { $this->_headers['Access-Control-Allow-Credentials'] = 'true'; return $this; } /** * Allowed headers that can be sent in CORS requests. * * @param array $headers The list of headers to accept in CORS requests. * @return $this */ public function allowHeaders(array $headers) { $this->_headers['Access-Control-Allow-Headers'] = implode(', ', $headers); return $this; } /** * Define the headers a client library/browser can expose to scripting * * @param array $headers The list of headers to expose CORS responses * @return $this */ public function exposeHeaders(array $headers) { $this->_headers['Access-Control-Expose-Headers'] = implode(', ', $headers); return $this; } /** * Define the max-age preflight OPTIONS requests are valid for. * * @param string|int $age The max-age for OPTIONS requests in seconds * @return $this */ public function maxAge($age) { $this->_headers['Access-Control-Max-Age'] = $age; return $this; } }