bool CrossOriginPreflightResultCacheItem::parse(const ResourceResponse& response, String& errorDescription) { m_methods.clear(); if (!parseAccessControlAllowList(response.httpHeaderField(HTTPNames::Access_Control_Allow_Methods), m_methods)) { errorDescription = "Cannot parse Access-Control-Allow-Methods response header field in preflight response."; return false; } m_headers.clear(); if (!parseAccessControlAllowList(response.httpHeaderField(HTTPNames::Access_Control_Allow_Headers), m_headers)) { errorDescription = "Cannot parse Access-Control-Allow-Headers response header field in preflight response."; return false; } unsigned expiryDelta; if (parseAccessControlMaxAge(response.httpHeaderField(HTTPNames::Access_Control_Max_Age), expiryDelta)) { if (expiryDelta > maxPreflightCacheTimeoutSeconds) expiryDelta = maxPreflightCacheTimeoutSeconds; } else { expiryDelta = defaultPreflightCacheTimeoutSeconds; } m_absoluteExpiryTime = currentTime() + expiryDelta; return true; }
bool PreflightResultCacheItem::parse(const ResourceResponse& response) { m_methods.clear(); if (!parseAccessControlAllowList(response.httpHeaderField("Access-Control-Allow-Methods"), m_methods)) return false; m_headers.clear(); if (!parseAccessControlAllowList(response.httpHeaderField("Access-Control-Allow-Headers"), m_headers)) return false; unsigned expiryDelta = 0; if (!parseAccessControlMaxAge(response.httpHeaderField("Access-Control-Max-Age"), expiryDelta)) expiryDelta = 5; m_absoluteExpiryTime = currentTime() + expiryDelta; return true; }
bool CrossOriginPreflightResultCacheItem::parse(const ResourceResponse& response, String& errorDescription) { m_methods.clear(); if (!parseAccessControlAllowList(response.httpHeaderField("Access-Control-Allow-Methods"), m_methods)) { errorDescription = "Cannot parse Access-Control-Allow-Methods response header field."; return false; } m_headers.clear(); if (!parseAccessControlAllowList(response.httpHeaderField("Access-Control-Allow-Headers"), m_headers)) { errorDescription = "Cannot parse Access-Control-Allow-Headers response header field."; return false; } unsigned expiryDelta; if (parseAccessControlMaxAge(response.httpHeaderField("Access-Control-Max-Age"), expiryDelta)) { if (expiryDelta > maxPreflightCacheTimeoutSeconds) expiryDelta = maxPreflightCacheTimeoutSeconds; } else expiryDelta = defaultPreflightCacheTimeoutSeconds; m_absoluteExpiryTime = monotonicallyIncreasingTime() + expiryDelta; return true; }
bool CrossOriginPreflightResultCacheItem::parse(const ResourceResponse& response, String& errorDescription) { m_methods.clear(); if (!parseAccessControlAllowList(response.httpHeaderField(HTTPHeaderName::AccessControlAllowMethods), m_methods)) { errorDescription = "Cannot parse Access-Control-Allow-Methods response header field."; return false; } m_headers.clear(); if (!parseAccessControlAllowList(response.httpHeaderField(HTTPHeaderName::AccessControlAllowHeaders), m_headers)) { errorDescription = "Cannot parse Access-Control-Allow-Headers response header field."; return false; } std::chrono::seconds expiryDelta; if (parseAccessControlMaxAge(response.httpHeaderField(HTTPHeaderName::AccessControlMaxAge), expiryDelta)) { if (expiryDelta > maxPreflightCacheTimeout) expiryDelta = maxPreflightCacheTimeout; } else expiryDelta = defaultPreflightCacheTimeout; m_absoluteExpiryTime = std::chrono::steady_clock::now() + expiryDelta; return true; }