| OLD | NEW | 
|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "net/url_request/url_request_http_job.h" | 5 #include "net/url_request/url_request_http_job.h" | 
| 6 | 6 | 
| 7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" | 
| 8 #include "base/bind.h" | 8 #include "base/bind.h" | 
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" | 
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" | 
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 343 | 343 | 
| 344   if (!is_cached_content_ && throttling_entry_.get()) | 344   if (!is_cached_content_ && throttling_entry_.get()) | 
| 345     throttling_entry_->UpdateWithResponse(GetResponseCode()); | 345     throttling_entry_->UpdateWithResponse(GetResponseCode()); | 
| 346 | 346 | 
| 347   if (!is_cached_content_) | 347   if (!is_cached_content_) | 
| 348     ProcessBackoffHeader(); | 348     ProcessBackoffHeader(); | 
| 349 | 349 | 
| 350   // The ordering of these calls is not important. | 350   // The ordering of these calls is not important. | 
| 351   ProcessStrictTransportSecurityHeader(); | 351   ProcessStrictTransportSecurityHeader(); | 
| 352   ProcessPublicKeyPinsHeader(); | 352   ProcessPublicKeyPinsHeader(); | 
|  | 353   ProcessExpectCTHeader(); | 
| 353 | 354 | 
| 354   // Handle the server notification of a new SDCH dictionary. | 355   // Handle the server notification of a new SDCH dictionary. | 
| 355   SdchManager* sdch_manager(request()->context()->sdch_manager()); | 356   SdchManager* sdch_manager(request()->context()->sdch_manager()); | 
| 356   if (sdch_manager) { | 357   if (sdch_manager) { | 
| 357     SdchProblemCode rv = sdch_manager->IsInSupportedDomain(request()->url()); | 358     SdchProblemCode rv = sdch_manager->IsInSupportedDomain(request()->url()); | 
| 358     if (rv != SDCH_OK) { | 359     if (rv != SDCH_OK) { | 
| 359       SdchManager::SdchErrorRecovery(rv); | 360       SdchManager::SdchErrorRecovery(rv); | 
| 360       request()->net_log().AddEvent( | 361       request()->net_log().AddEvent( | 
| 361           NetLog::TYPE_SDCH_DECODING_ERROR, | 362           NetLog::TYPE_SDCH_DECODING_ERROR, | 
| 362           base::Bind(&NetLogSdchResourceProblemCallback, rv)); | 363           base::Bind(&NetLogSdchResourceProblemCallback, rv)); | 
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 843   std::string value; | 844   std::string value; | 
| 844   if (headers->EnumerateHeader(nullptr, "Public-Key-Pins", &value)) | 845   if (headers->EnumerateHeader(nullptr, "Public-Key-Pins", &value)) | 
| 845     security_state->AddHPKPHeader(request_info_.url.host(), value, ssl_info); | 846     security_state->AddHPKPHeader(request_info_.url.host(), value, ssl_info); | 
| 846   if (headers->EnumerateHeader(nullptr, "Public-Key-Pins-Report-Only", | 847   if (headers->EnumerateHeader(nullptr, "Public-Key-Pins-Report-Only", | 
| 847                                &value)) { | 848                                &value)) { | 
| 848     security_state->ProcessHPKPReportOnlyHeader( | 849     security_state->ProcessHPKPReportOnlyHeader( | 
| 849         value, HostPortPair::FromURL(request_info_.url), ssl_info); | 850         value, HostPortPair::FromURL(request_info_.url), ssl_info); | 
| 850   } | 851   } | 
| 851 } | 852 } | 
| 852 | 853 | 
|  | 854 void URLRequestHttpJob::ProcessExpectCTHeader() { | 
|  | 855   DCHECK(response_info_); | 
|  | 856   TransportSecurityState* security_state = | 
|  | 857       request_->context()->transport_security_state(); | 
|  | 858   const SSLInfo& ssl_info = response_info_->ssl_info; | 
|  | 859 | 
|  | 860   // Only accept Expect CT headers on HTTPS connections that have no | 
|  | 861   // certificate errors. | 
|  | 862   if (!ssl_info.is_valid() || IsCertStatusError(ssl_info.cert_status) || | 
|  | 863       !security_state) { | 
|  | 864     return; | 
|  | 865   } | 
|  | 866 | 
|  | 867   // Only process the first Expect-CT header value. | 
|  | 868   HttpResponseHeaders* headers = GetResponseHeaders(); | 
|  | 869   std::string value; | 
|  | 870   if (headers->EnumerateHeader(nullptr, "Expect-CT", &value)) { | 
|  | 871     security_state->ProcessExpectCTHeader( | 
|  | 872         value, HostPortPair::FromURL(request_info_.url), ssl_info); | 
|  | 873   } | 
|  | 874 } | 
|  | 875 | 
| 853 void URLRequestHttpJob::OnStartCompleted(int result) { | 876 void URLRequestHttpJob::OnStartCompleted(int result) { | 
| 854   RecordTimer(); | 877   RecordTimer(); | 
| 855 | 878 | 
| 856   // If the request was destroyed, then there is no more work to do. | 879   // If the request was destroyed, then there is no more work to do. | 
| 857   if (!request_) | 880   if (!request_) | 
| 858     return; | 881     return; | 
| 859 | 882 | 
| 860   // If the job is done (due to cancellation), can just ignore this | 883   // If the job is done (due to cancellation), can just ignore this | 
| 861   // notification. | 884   // notification. | 
| 862   if (done_) | 885   if (done_) | 
| (...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1522   return override_response_headers_.get() ? | 1545   return override_response_headers_.get() ? | 
| 1523              override_response_headers_.get() : | 1546              override_response_headers_.get() : | 
| 1524              transaction_->GetResponseInfo()->headers.get(); | 1547              transaction_->GetResponseInfo()->headers.get(); | 
| 1525 } | 1548 } | 
| 1526 | 1549 | 
| 1527 void URLRequestHttpJob::NotifyURLRequestDestroyed() { | 1550 void URLRequestHttpJob::NotifyURLRequestDestroyed() { | 
| 1528   awaiting_callback_ = false; | 1551   awaiting_callback_ = false; | 
| 1529 } | 1552 } | 
| 1530 | 1553 | 
| 1531 }  // namespace net | 1554 }  // namespace net | 
| OLD | NEW | 
|---|