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 |