| OLD | NEW |
| 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 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 response_data->SetURLList(url_list_); | 443 response_data->SetURLList(url_list_); |
| 444 } else { | 444 } else { |
| 445 DCHECK(response.WasFetchedViaServiceWorker()); | 445 DCHECK(response.WasFetchedViaServiceWorker()); |
| 446 response_data->SetURLList(response.UrlListViaServiceWorker()); | 446 response_data->SetURLList(response.UrlListViaServiceWorker()); |
| 447 } | 447 } |
| 448 response_data->SetMIMEType(response.MimeType()); | 448 response_data->SetMIMEType(response.MimeType()); |
| 449 response_data->SetResponseTime(response.ResponseTime()); | 449 response_data->SetResponseTime(response.ResponseTime()); |
| 450 | 450 |
| 451 FetchResponseData* tainted_response = nullptr; | 451 FetchResponseData* tainted_response = nullptr; |
| 452 | 452 |
| 453 if (NetworkUtils::IsRedirectResponseCode(response_http_status_code_)) { | 453 DCHECK(!(NetworkUtils::IsRedirectResponseCode(response_http_status_code_) && |
| 454 Vector<String> locations; | 454 response_data->HeaderList()->Has(HTTPNames::Location) && |
| 455 response_data->HeaderList()->GetAll(HTTPNames::Location, locations); | 455 request_->Redirect() != WebURLRequest::kFetchRedirectModeManual)); |
| 456 if (locations.size() > 1) { | 456 |
| 457 PerformNetworkError("Multiple Location header."); | 457 if (NetworkUtils::IsRedirectResponseCode(response_http_status_code_) && |
| 458 return; | 458 request_->Redirect() == WebURLRequest::kFetchRedirectModeManual) { |
| 459 } | 459 tainted_response = response_data->CreateOpaqueRedirectFilteredResponse(); |
| 460 if (locations.size() == 1) { | 460 } else { |
| 461 KURL location_url(request_->Url(), locations[0]); | |
| 462 if (!location_url.IsValid()) { | |
| 463 PerformNetworkError("Invalid Location header."); | |
| 464 return; | |
| 465 } | |
| 466 ASSERT(request_->Redirect() == WebURLRequest::kFetchRedirectModeManual); | |
| 467 tainted_response = response_data->CreateOpaqueRedirectFilteredResponse(); | |
| 468 } | |
| 469 // When the location header doesn't exist, we don't treat the response | |
| 470 // as a redirect response, and execute tainting. | |
| 471 } | |
| 472 if (!tainted_response) { | |
| 473 switch (tainting) { | 461 switch (tainting) { |
| 474 case FetchRequestData::kBasicTainting: | 462 case FetchRequestData::kBasicTainting: |
| 475 tainted_response = response_data->CreateBasicFilteredResponse(); | 463 tainted_response = response_data->CreateBasicFilteredResponse(); |
| 476 break; | 464 break; |
| 477 case FetchRequestData::kCORSTainting: { | 465 case FetchRequestData::kCORSTainting: { |
| 478 HTTPHeaderSet header_names; | 466 HTTPHeaderSet header_names; |
| 479 ExtractCorsExposedHeaderNamesList(response, header_names); | 467 ExtractCorsExposedHeaderNamesList(response, header_names); |
| 480 tainted_response = | 468 tainted_response = |
| 481 response_data->CreateCORSFilteredResponse(header_names); | 469 response_data->CreateCORSFilteredResponse(header_names); |
| 482 break; | 470 break; |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 935 loaders_.erase(loader); | 923 loaders_.erase(loader); |
| 936 loader->Dispose(); | 924 loader->Dispose(); |
| 937 } | 925 } |
| 938 | 926 |
| 939 DEFINE_TRACE(FetchManager) { | 927 DEFINE_TRACE(FetchManager) { |
| 940 visitor->Trace(loaders_); | 928 visitor->Trace(loaders_); |
| 941 ContextLifecycleObserver::Trace(visitor); | 929 ContextLifecycleObserver::Trace(visitor); |
| 942 } | 930 } |
| 943 | 931 |
| 944 } // namespace blink | 932 } // namespace blink |
| OLD | NEW |