| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved. |
| 3 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. | 3 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #include "platform/network/ResourceRequest.h" | 27 #include "platform/network/ResourceRequest.h" |
| 28 | 28 |
| 29 #include "platform/HTTPNames.h" | 29 #include "platform/HTTPNames.h" |
| 30 #include "platform/RuntimeEnabledFeatures.h" | 30 #include "platform/RuntimeEnabledFeatures.h" |
| 31 #include "platform/weborigin/SecurityOrigin.h" | 31 #include "platform/weborigin/SecurityOrigin.h" |
| 32 #include "public/platform/Platform.h" | 32 #include "public/platform/Platform.h" |
| 33 #include "public/platform/WebAddressSpace.h" |
| 33 #include "public/platform/WebURLRequest.h" | 34 #include "public/platform/WebURLRequest.h" |
| 34 | 35 |
| 35 namespace blink { | 36 namespace blink { |
| 36 | 37 |
| 37 double ResourceRequest::s_defaultTimeoutInterval = INT_MAX; | 38 double ResourceRequest::s_defaultTimeoutInterval = INT_MAX; |
| 38 | 39 |
| 39 ResourceRequest::ResourceRequest(CrossThreadResourceRequestData* data) | 40 ResourceRequest::ResourceRequest(CrossThreadResourceRequestData* data) |
| 40 : ResourceRequest() | 41 : ResourceRequest() |
| 41 { | 42 { |
| 42 setURL(data->m_url); | 43 setURL(data->m_url); |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 { | 367 { |
| 367 if (!equalIgnoringHeaderFields(a, b)) | 368 if (!equalIgnoringHeaderFields(a, b)) |
| 368 return false; | 369 return false; |
| 369 | 370 |
| 370 if (a.httpHeaderFields() != b.httpHeaderFields()) | 371 if (a.httpHeaderFields() != b.httpHeaderFields()) |
| 371 return false; | 372 return false; |
| 372 | 373 |
| 373 return true; | 374 return true; |
| 374 } | 375 } |
| 375 | 376 |
| 376 void ResourceRequest::setExternalRequestStateFromRequestorAddressSpace(WebURLReq
uest::AddressSpace requestorSpace) | 377 void ResourceRequest::setExternalRequestStateFromRequestorAddressSpace(WebAddres
sSpace requestorSpace) |
| 377 { | 378 { |
| 378 static_assert(WebURLRequest::AddressSpaceLocal < WebURLRequest::AddressSpace
Private, "Local is inside Private"); | 379 static_assert(WebAddressSpaceLocal < WebAddressSpacePrivate, "Local is insid
e Private"); |
| 379 static_assert(WebURLRequest::AddressSpaceLocal < WebURLRequest::AddressSpace
Public, "Local is inside Public"); | 380 static_assert(WebAddressSpaceLocal < WebAddressSpacePublic, "Local is inside
Public"); |
| 380 static_assert(WebURLRequest::AddressSpacePrivate < WebURLRequest::AddressSpa
cePublic, "Private is inside Public"); | 381 static_assert(WebAddressSpacePrivate < WebAddressSpacePublic, "Private is in
side Public"); |
| 381 | 382 |
| 382 // TODO(mkwst): This only checks explicit IP addresses. We'll have to move a
ll this up to //net and //content in | 383 // TODO(mkwst): This only checks explicit IP addresses. We'll have to move a
ll this up to //net and //content in |
| 383 // order to have any real impact on gateway attacks. That turns out to be a
TON of work. https://crbug.com/378566 | 384 // order to have any real impact on gateway attacks. That turns out to be a
TON of work. https://crbug.com/378566 |
| 384 if (!RuntimeEnabledFeatures::corsRFC1918Enabled()) { | 385 if (!RuntimeEnabledFeatures::corsRFC1918Enabled()) { |
| 385 m_isExternalRequest = false; | 386 m_isExternalRequest = false; |
| 386 return; | 387 return; |
| 387 } | 388 } |
| 388 | 389 |
| 389 WebURLRequest::AddressSpace targetSpace = WebURLRequest::AddressSpacePublic; | 390 WebAddressSpace targetSpace = WebAddressSpacePublic; |
| 390 if (Platform::current()->isReservedIPAddress(m_url.host())) | 391 if (Platform::current()->isReservedIPAddress(m_url.host())) |
| 391 targetSpace = WebURLRequest::AddressSpacePrivate; | 392 targetSpace = WebAddressSpacePrivate; |
| 392 if (SecurityOrigin::create(m_url)->isLocalhost()) | 393 if (SecurityOrigin::create(m_url)->isLocalhost()) |
| 393 targetSpace = WebURLRequest::AddressSpaceLocal; | 394 targetSpace = WebAddressSpaceLocal; |
| 394 | 395 |
| 395 m_isExternalRequest = requestorSpace > targetSpace; | 396 m_isExternalRequest = requestorSpace > targetSpace; |
| 396 } | 397 } |
| 397 | 398 |
| 398 bool ResourceRequest::isConditional() const | 399 bool ResourceRequest::isConditional() const |
| 399 { | 400 { |
| 400 return (m_httpHeaderFields.contains(HTTPNames::If_Match) | 401 return (m_httpHeaderFields.contains(HTTPNames::If_Match) |
| 401 || m_httpHeaderFields.contains(HTTPNames::If_Modified_Since) | 402 || m_httpHeaderFields.contains(HTTPNames::If_Modified_Since) |
| 402 || m_httpHeaderFields.contains(HTTPNames::If_None_Match) | 403 || m_httpHeaderFields.contains(HTTPNames::If_None_Match) |
| 403 || m_httpHeaderFields.contains(HTTPNames::If_Range) | 404 || m_httpHeaderFields.contains(HTTPNames::If_Range) |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 m_didSetHTTPReferrer = false; | 461 m_didSetHTTPReferrer = false; |
| 461 m_checkForBrowserSideNavigation = true; | 462 m_checkForBrowserSideNavigation = true; |
| 462 m_uiStartTime = 0; | 463 m_uiStartTime = 0; |
| 463 m_isExternalRequest = false; | 464 m_isExternalRequest = false; |
| 464 m_inputPerfMetricReportPolicy = InputToLoadPerfMetricReportPolicy::NoReport; | 465 m_inputPerfMetricReportPolicy = InputToLoadPerfMetricReportPolicy::NoReport; |
| 465 m_followedRedirect = false; | 466 m_followedRedirect = false; |
| 466 m_requestorOrigin = SecurityOrigin::createUnique(); | 467 m_requestorOrigin = SecurityOrigin::createUnique(); |
| 467 } | 468 } |
| 468 | 469 |
| 469 } // namespace blink | 470 } // namespace blink |
| OLD | NEW |