Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(831)

Unified Diff: Source/core/loader/DocumentThreadableLoader.cpp

Issue 1196423003: Improve console log message for CORS failure (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/loader/DocumentThreadableLoader.cpp
diff --git a/Source/core/loader/DocumentThreadableLoader.cpp b/Source/core/loader/DocumentThreadableLoader.cpp
index f33cff26d4e913122b92fac461e3dc600d073463..6f9d12c98a04819ff87a5808cfe4d59b2f3be406 100644
--- a/Source/core/loader/DocumentThreadableLoader.cpp
+++ b/Source/core/loader/DocumentThreadableLoader.cpp
@@ -299,12 +299,17 @@ void DocumentThreadableLoader::redirectReceived(Resource* resource, ResourceRequ
// Non-simple cross origin requests (both preflight and actual one) are
// not allowed to follow redirect.
if (m_crossOriginNonSimpleRequest) {
- accessControlErrorDescription = "The request was redirected to '"+ request.url().string() + "', which is disallowed for cross-origin requests that require preflight.";
+ accessControlErrorDescription = "The request was redirected to '" + request.url().string() + "', which is disallowed for cross-origin requests that require preflight.";
} else {
// The redirect response must pass the access control check if the
// original request was not same-origin.
- allowRedirect = CrossOriginAccessControl::isLegalRedirectLocation(request.url(), accessControlErrorDescription)
- && (m_sameOriginRequest || passesAccessControlCheck(redirectResponse, effectiveAllowCredentials(), securityOrigin(), accessControlErrorDescription));
+ if (CrossOriginAccessControl::isLegalRedirectLocation(request.url(), accessControlErrorDescription)) {
+ if (m_sameOriginRequest || passesAccessControlCheck(redirectResponse, effectiveAllowCredentials(), securityOrigin(), accessControlErrorDescription)) {
+ allowRedirect = true;
+ } else {
+ accessControlErrorDescription = "The request was redirected to '" + request.url().string() + "', and has been blocked from loading by Cross-Origin Resource Sharing policy: " + accessControlErrorDescription;
+ }
+ }
}
if (allowRedirect) {
@@ -394,7 +399,7 @@ void DocumentThreadableLoader::handlePreflightResponse(const ResourceResponse& r
String accessControlErrorDescription;
if (!passesAccessControlCheck(response, effectiveAllowCredentials(), securityOrigin(), accessControlErrorDescription)) {
- handlePreflightFailure(response.url().string(), accessControlErrorDescription);
+ handlePreflightFailure(response.url().string(), "Response for preflight doesn't pass the access control check: " + accessControlErrorDescription);
return;
}
@@ -458,7 +463,7 @@ void DocumentThreadableLoader::handleResponse(unsigned long identifier, const Re
String accessControlErrorDescription;
if (!passesAccessControlCheck(response, effectiveAllowCredentials(), securityOrigin(), accessControlErrorDescription)) {
reportResponseReceived(identifier, response);
- m_client->didFailAccessControlCheck(ResourceError(errorDomainBlinkInternal, 0, response.url().string(), accessControlErrorDescription));
+ m_client->didFailAccessControlCheck(ResourceError(errorDomainBlinkInternal, 0, response.url().string(), "Received response but it doesn't pass the access control check: " + accessControlErrorDescription));
sof 2015/06/25 11:24:18 The prefixed text strikes me as redundant (and lon
tyoshino (SeeGerritForStatus) 2016/07/22 12:46:45 OK. Removed
return;
}
}

Powered by Google App Engine
This is Rietveld 408576698