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

Side by Side Diff: third_party/WebKit/Source/modules/fetch/FetchManager.cpp

Issue 2532833002: Reflect method restriction removal from Fetch API on data URL (Closed)
Patch Set: Rebase Created 4 years 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/fetch/script-tests/thorough/scheme-data.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "modules/fetch/FetchManager.h" 5 #include "modules/fetch/FetchManager.h"
6 6
7 #include "bindings/core/v8/ExceptionState.h" 7 #include "bindings/core/v8/ExceptionState.h"
8 #include "bindings/core/v8/ScriptPromiseResolver.h" 8 #include "bindings/core/v8/ScriptPromiseResolver.h"
9 #include "bindings/core/v8/ScriptState.h" 9 #include "bindings/core/v8/ScriptState.h"
10 #include "bindings/core/v8/V8ThrowException.h" 10 #include "bindings/core/v8/V8ThrowException.h"
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 m_loader->start(request); 825 m_loader->start(request);
826 } 826 }
827 827
828 // performDataFetch() is almost the same as performHTTPFetch(), except for: 828 // performDataFetch() is almost the same as performHTTPFetch(), except for:
829 // - We set AllowCrossOriginRequests to allow requests to data: URLs in 829 // - We set AllowCrossOriginRequests to allow requests to data: URLs in
830 // 'same-origin' mode. 830 // 'same-origin' mode.
831 // - We reject non-GET method. 831 // - We reject non-GET method.
832 void FetchManager::Loader::performDataFetch() { 832 void FetchManager::Loader::performDataFetch() {
833 ASSERT(m_request->url().protocolIsData()); 833 ASSERT(m_request->url().protocolIsData());
834 834
835 // Spec: https://fetch.spec.whatwg.org/#concept-basic-fetch
836 // If |request|'s method is `GET` .... Otherwise, return a network error.
837 if (m_request->method() != HTTPNames::GET) {
838 performNetworkError(
839 "Only 'GET' method is allowed for data URLs in Fetch API.");
840 return;
841 }
842
843 ResourceRequest request(m_request->url()); 835 ResourceRequest request(m_request->url());
844 request.setRequestContext(m_request->context()); 836 request.setRequestContext(m_request->context());
845 request.setUseStreamOnResponse(true); 837 request.setUseStreamOnResponse(true);
846 request.setHTTPMethod(m_request->method()); 838 request.setHTTPMethod(m_request->method());
847 request.setFetchRedirectMode(WebURLRequest::FetchRedirectModeError); 839 request.setFetchRedirectMode(WebURLRequest::FetchRedirectModeError);
848 // We intentionally skip 'setExternalRequestStateFromRequestorAddressSpace', 840 // We intentionally skip 'setExternalRequestStateFromRequestorAddressSpace',
849 // as 'data:' can never be external. 841 // as 'data:' can never be external.
850 842
851 ResourceLoaderOptions resourceLoaderOptions; 843 ResourceLoaderOptions resourceLoaderOptions;
852 resourceLoaderOptions.dataBufferingPolicy = DoNotBufferData; 844 resourceLoaderOptions.dataBufferingPolicy = DoNotBufferData;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 m_loaders.remove(loader); 915 m_loaders.remove(loader);
924 loader->dispose(); 916 loader->dispose();
925 } 917 }
926 918
927 DEFINE_TRACE(FetchManager) { 919 DEFINE_TRACE(FetchManager) {
928 visitor->trace(m_loaders); 920 visitor->trace(m_loaders);
929 ContextLifecycleObserver::trace(visitor); 921 ContextLifecycleObserver::trace(visitor);
930 } 922 }
931 923
932 } // namespace blink 924 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/fetch/script-tests/thorough/scheme-data.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698