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

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

Issue 1371393003: [Fetch] Support blob: scheme (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 years, 2 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 | « third_party/WebKit/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: third_party/WebKit/Source/modules/fetch/FetchManager.cpp
diff --git a/third_party/WebKit/Source/modules/fetch/FetchManager.cpp b/third_party/WebKit/Source/modules/fetch/FetchManager.cpp
index de11d01eacba02d9ce62131fed128e9d05840851..e742559726563a778b8a69ab133559dde66750f8 100644
--- a/third_party/WebKit/Source/modules/fetch/FetchManager.cpp
+++ b/third_party/WebKit/Source/modules/fetch/FetchManager.cpp
@@ -204,6 +204,18 @@ 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) {
+ performNetworkError("Only 'GET' method is allowed for blob URLs.");
+ return;
+ }
+
m_responseHttpStatusCode = response.httpStatusCode();
if (response.url().protocolIsData()) {
@@ -481,6 +493,8 @@ void FetchManager::Loader::performBasicFetch()
performHTTPFetch(false, false);
} else if (m_request->url().protocolIsData()) {
performDataFetch();
+ } 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.");
@@ -494,7 +508,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 | « third_party/WebKit/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