public function validateHeaders(WebRequest $request)
    {
        $settings = CsrfSettings::singleton();

        $headersValid = false;

        $referrerDomain = $this->getHost($request->header("Referer", ""));

        if ($referrerDomain != "") {
            if ($referrerDomain == $settings->domain){
                $headersValid = true;
            }
        } else {
            if ($this->getHost($request->header("Origin")) == $settings->domain) {
                $headersValid = true;
            }
        }

        if (!$headersValid){
            throw new CsrfViolationException();
        }
    }