OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/base_switches.h" | 8 #include "base/base_switches.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 if (!is_cached_content_) { | 248 if (!is_cached_content_) { |
249 URLRequestThrottlerHeaderAdapter response_adapter(GetResponseHeaders()); | 249 URLRequestThrottlerHeaderAdapter response_adapter(GetResponseHeaders()); |
250 throttling_entry_->UpdateWithResponse(request_info_.url.host(), | 250 throttling_entry_->UpdateWithResponse(request_info_.url.host(), |
251 &response_adapter); | 251 &response_adapter); |
252 } | 252 } |
253 | 253 |
254 ProcessStrictTransportSecurityHeader(); | 254 ProcessStrictTransportSecurityHeader(); |
255 | 255 |
256 if (SdchManager::Global() && | 256 if (SdchManager::Global() && |
257 SdchManager::Global()->IsInSupportedDomain(request_->url())) { | 257 SdchManager::Global()->IsInSupportedDomain(request_->url())) { |
258 static const std::string name = "Get-Dictionary"; | 258 const std::string name = "Get-Dictionary"; |
259 std::string url_text; | 259 std::string url_text; |
260 void* iter = NULL; | 260 void* iter = NULL; |
261 // TODO(jar): We need to not fetch dictionaries the first time they are | 261 // TODO(jar): We need to not fetch dictionaries the first time they are |
262 // seen, but rather wait until we can justify their usefulness. | 262 // seen, but rather wait until we can justify their usefulness. |
263 // For now, we will only fetch the first dictionary, which will at least | 263 // For now, we will only fetch the first dictionary, which will at least |
264 // require multiple suggestions before we get additional ones for this site. | 264 // require multiple suggestions before we get additional ones for this site. |
265 // Eventually we should wait until a dictionary is requested several times | 265 // Eventually we should wait until a dictionary is requested several times |
266 // before we even download it (so that we don't waste memory or bandwidth). | 266 // before we even download it (so that we don't waste memory or bandwidth). |
267 if (GetResponseHeaders()->EnumerateHeader(&iter, name, &url_text)) { | 267 if (GetResponseHeaders()->EnumerateHeader(&iter, name, &url_text)) { |
268 // request_->url() won't be valid in the destructor, so we use an | 268 // request_->url() won't be valid in the destructor, so we use an |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 // We may have been canceled within OnSetCookie. | 585 // We may have been canceled within OnSetCookie. |
586 if (GetStatus().is_success()) { | 586 if (GetStatus().is_success()) { |
587 SaveNextCookie(); | 587 SaveNextCookie(); |
588 } else { | 588 } else { |
589 NotifyCanceled(); | 589 NotifyCanceled(); |
590 } | 590 } |
591 } | 591 } |
592 | 592 |
593 void URLRequestHttpJob::FetchResponseCookies( | 593 void URLRequestHttpJob::FetchResponseCookies( |
594 std::vector<std::string>* cookies) { | 594 std::vector<std::string>* cookies) { |
595 std::string name = "Set-Cookie"; | 595 const std::string name = "Set-Cookie"; |
596 std::string value; | 596 std::string value; |
597 | 597 |
598 void* iter = NULL; | 598 void* iter = NULL; |
599 HttpResponseHeaders* headers = GetResponseHeaders(); | 599 HttpResponseHeaders* headers = GetResponseHeaders(); |
600 while (headers->EnumerateHeader(&iter, name, &value)) { | 600 while (headers->EnumerateHeader(&iter, name, &value)) { |
601 if (!value.empty()) | 601 if (!value.empty()) |
602 cookies->push_back(value); | 602 cookies->push_back(value); |
603 } | 603 } |
604 } | 604 } |
605 | 605 |
606 void URLRequestHttpJob::ProcessStrictTransportSecurityHeader() { | 606 void URLRequestHttpJob::ProcessStrictTransportSecurityHeader() { |
607 DCHECK(response_info_); | 607 DCHECK(response_info_); |
608 | 608 |
609 const URLRequestContext* ctx = request_->context(); | 609 const URLRequestContext* ctx = request_->context(); |
610 if (!ctx || !ctx->transport_security_state()) | 610 if (!ctx || !ctx->transport_security_state()) |
611 return; | 611 return; |
612 | 612 |
613 const bool https = response_info_->ssl_info.is_valid(); | 613 const bool https = response_info_->ssl_info.is_valid(); |
614 const bool valid_https = | 614 const bool valid_https = |
615 https && !IsCertStatusError(response_info_->ssl_info.cert_status); | 615 https && !IsCertStatusError(response_info_->ssl_info.cert_status); |
616 | 616 |
617 std::string name = "Strict-Transport-Security"; | 617 const std::string name = "Strict-Transport-Security"; |
618 std::string value; | 618 std::string value; |
619 | 619 |
620 int max_age; | 620 int max_age; |
621 bool include_subdomains; | 621 bool include_subdomains; |
622 | 622 |
623 HttpResponseHeaders* headers = GetResponseHeaders(); | 623 HttpResponseHeaders* headers = GetResponseHeaders(); |
624 | 624 |
625 void* iter = NULL; | 625 void* iter = NULL; |
626 while (headers->EnumerateHeader(&iter, name, &value)) { | 626 while (headers->EnumerateHeader(&iter, name, &value)) { |
627 const bool ok = TransportSecurityState::ParseHeader( | 627 const bool ok = TransportSecurityState::ParseHeader( |
(...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1426 return override_response_headers_.get() ? | 1426 return override_response_headers_.get() ? |
1427 override_response_headers_ : | 1427 override_response_headers_ : |
1428 transaction_->GetResponseInfo()->headers; | 1428 transaction_->GetResponseInfo()->headers; |
1429 } | 1429 } |
1430 | 1430 |
1431 void URLRequestHttpJob::NotifyURLRequestDestroyed() { | 1431 void URLRequestHttpJob::NotifyURLRequestDestroyed() { |
1432 awaiting_callback_ = false; | 1432 awaiting_callback_ = false; |
1433 } | 1433 } |
1434 | 1434 |
1435 } // namespace net | 1435 } // namespace net |
OLD | NEW |