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

Unified Diff: Source/modules/fetch/FetchManager.cpp

Issue 1336933003: [Migrated][Fetch] Support blob: scheme (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Network Error for non-GET blob URLs. Created 5 years, 3 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
« no previous file with comments | « LayoutTests/http/tests/fetch/workers/thorough/scheme-blob-other-https.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/fetch/FetchManager.cpp
diff --git a/Source/modules/fetch/FetchManager.cpp b/Source/modules/fetch/FetchManager.cpp
index 906d6808f299d672cbd02700c160aff289e90496..658cc7485ce0f0dc4a32c1326b9bc78093d45efb 100644
--- a/Source/modules/fetch/FetchManager.cpp
+++ b/Source/modules/fetch/FetchManager.cpp
@@ -202,6 +202,19 @@ void FetchManager::Loader::didReceiveResponse(unsigned long, const ResourceRespo
{
ASSERT(handle);
+ if (response.url().protocolIs("blob") && response.httpStatusCode() == 404) {
+ // "If |blob| is null, return a network error."
+ // https://fetch.spec.whatwg.org/#concept-basic-fetch
+ performNetworkError("Blob not found.");
+ return;
+ }
+
+ if (response.url().protocolIs("blob") && response.httpStatusCode() == 405) {
+ // TODO(hiroshige): Spec will be updated https://github.com/whatwg/fetch/issues/125. Update this comment with citing the new spec before commit.
yhirano 2015/10/06 05:02:01 The issue was closed.
+ performNetworkError("Only 'GET' method is allowed for blob URLs.");
+ return;
+ }
+
m_responseHttpStatusCode = response.httpStatusCode();
// Recompute the tainting if the request was redirected to a different
@@ -446,6 +459,8 @@ void FetchManager::Loader::performBasicFetch()
if (SchemeRegistry::shouldTreatURLSchemeAsSupportingFetchAPI(m_request->url().protocol())) {
// "Return the result of performing an HTTP fetch using |request|."
performHTTPFetch(false, false);
+ } else if (m_request->url().protocolIs("blob")) {
+ performHTTPFetch(false, false);
} else {
// FIXME: implement other protocols.
performNetworkError("Fetch API cannot load " + m_request->url().string() + ". URL scheme \"" + m_request->url().protocol() + "\" is not supported.");
@@ -459,7 +474,7 @@ void FetchManager::Loader::performNetworkError(const String& message)
void FetchManager::Loader::performHTTPFetch(bool corsFlag, bool corsPreflightFlag)
{
- ASSERT(SchemeRegistry::shouldTreatURLSchemeAsSupportingFetchAPI(m_request->url().protocol()));
+ ASSERT(SchemeRegistry::shouldTreatURLSchemeAsSupportingFetchAPI(m_request->url().protocol()) || (m_request->url().protocolIs("blob") && !corsFlag && !corsPreflightFlag));
// CORS preflight fetch procedure is implemented inside DocumentThreadableLoader.
// "1. Let |HTTPRequest| be a copy of |request|, except that |HTTPRequest|'s
« no previous file with comments | « LayoutTests/http/tests/fetch/workers/thorough/scheme-blob-other-https.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698