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

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

Issue 2785123002: Make no-location redirect response to be "opaque redirect" when redirect mode is manual. (Closed)
Patch Set: Created 3 years, 8 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 unified diff | Download patch
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 <memory> 7 #include <memory>
8 #include "bindings/core/v8/ExceptionState.h" 8 #include "bindings/core/v8/ExceptionState.h"
9 #include "bindings/core/v8/ScriptPromiseResolver.h" 9 #include "bindings/core/v8/ScriptPromiseResolver.h"
10 #include "bindings/core/v8/ScriptState.h" 10 #include "bindings/core/v8/ScriptState.h"
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 responseData->setURLList(m_urlList); 441 responseData->setURLList(m_urlList);
442 } else { 442 } else {
443 DCHECK(response.wasFetchedViaServiceWorker()); 443 DCHECK(response.wasFetchedViaServiceWorker());
444 responseData->setURLList(response.urlListViaServiceWorker()); 444 responseData->setURLList(response.urlListViaServiceWorker());
445 } 445 }
446 responseData->setMIMEType(response.mimeType()); 446 responseData->setMIMEType(response.mimeType());
447 responseData->setResponseTime(response.responseTime()); 447 responseData->setResponseTime(response.responseTime());
448 448
449 FetchResponseData* taintedResponse = nullptr; 449 FetchResponseData* taintedResponse = nullptr;
450 450
451 if (NetworkUtils::isRedirectResponseCode(m_responseHttpStatusCode)) { 451 DCHECK(!(NetworkUtils::isRedirectResponseCode(m_responseHttpStatusCode) &&
452 Vector<String> locations; 452 responseData->headerList()->has(HTTPNames::Location) &&
453 responseData->headerList()->getAll(HTTPNames::Location, locations); 453 m_request->redirect() != WebURLRequest::FetchRedirectModeManual));
454 if (locations.size() > 1) { 454
455 performNetworkError("Multiple Location header."); 455 if (NetworkUtils::isRedirectResponseCode(m_responseHttpStatusCode) &&
456 return; 456 m_request->redirect() == WebURLRequest::FetchRedirectModeManual) {
457 } 457 taintedResponse = responseData->createOpaqueRedirectFilteredResponse();
458 if (locations.size() == 1) { 458 } else {
459 KURL locationURL(m_request->url(), locations[0]);
460 if (!locationURL.isValid()) {
461 performNetworkError("Invalid Location header.");
462 return;
463 }
464 ASSERT(m_request->redirect() == WebURLRequest::FetchRedirectModeManual);
465 taintedResponse = responseData->createOpaqueRedirectFilteredResponse();
466 }
467 // When the location header doesn't exist, we don't treat the response
468 // as a redirect response, and execute tainting.
469 }
470 if (!taintedResponse) {
471 switch (tainting) { 459 switch (tainting) {
472 case FetchRequestData::BasicTainting: 460 case FetchRequestData::BasicTainting:
473 taintedResponse = responseData->createBasicFilteredResponse(); 461 taintedResponse = responseData->createBasicFilteredResponse();
474 break; 462 break;
475 case FetchRequestData::CORSTainting: { 463 case FetchRequestData::CORSTainting: {
476 HTTPHeaderSet headerNames; 464 HTTPHeaderSet headerNames;
477 extractCorsExposedHeaderNamesList(response, headerNames); 465 extractCorsExposedHeaderNamesList(response, headerNames);
478 taintedResponse = responseData->createCORSFilteredResponse(headerNames); 466 taintedResponse = responseData->createCORSFilteredResponse(headerNames);
479 break; 467 break;
480 } 468 }
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 m_loaders.erase(loader); 920 m_loaders.erase(loader);
933 loader->dispose(); 921 loader->dispose();
934 } 922 }
935 923
936 DEFINE_TRACE(FetchManager) { 924 DEFINE_TRACE(FetchManager) {
937 visitor->trace(m_loaders); 925 visitor->trace(m_loaders);
938 ContextLifecycleObserver::trace(visitor); 926 ContextLifecycleObserver::trace(visitor);
939 } 927 }
940 928
941 } // namespace blink 929 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698