public function checkReferer(Request $request) { if ($this->isEnabled()) { return; } $referer = $request->server('HTTP_REFERER'); $parts = parse_url($referer); $host = $parts['host']; $method = $request->server('REQUEST_METHOD'); if (!in_array($method, ['GET', 'HEAD', 'OPTIONS']) && $host && $host != $request->server('HTTP_HOST')) { throw new HttpException("Invalid referer", 400); } }
public function match(Request $request) { if (in_array($request->method, ['GET', 'DELETE', 'HEAD', 'OPTIONS'])) { return true; } $contentType = HttpHelper::cleanContentType($request->server('CONTENT_TYPE')); if (!$contentType) { return true; } return in_array($contentType, $this->types); }