| 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/base_switches.h" | 7 #include "base/base_switches.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/file_version_info.h" | 11 #include "base/file_version_info.h" |
| 12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 13 #include "base/metrics/field_trial.h" | 13 #include "base/metrics/field_trial.h" |
| 14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
| 15 #include "base/rand_util.h" | 15 #include "base/rand_util.h" |
| 16 #include "base/string_util.h" | 16 #include "base/string_util.h" |
| 17 #include "base/time.h" | 17 #include "base/time.h" |
| 18 #include "net/base/cert_status_flags.h" | 18 #include "net/base/cert_status_flags.h" |
| 19 #include "net/base/cookie_store.h" | 19 #include "net/base/cookie_store.h" |
| 20 #include "net/base/filter.h" | 20 #include "net/base/filter.h" |
| 21 #include "net/base/host_port_pair.h" | 21 #include "net/base/host_port_pair.h" |
| 22 #include "net/base/load_flags.h" | 22 #include "net/base/load_flags.h" |
| 23 #include "net/base/mime_util.h" | 23 #include "net/base/mime_util.h" |
| 24 #include "net/base/net_errors.h" | 24 #include "net/base/net_errors.h" |
| 25 #include "net/base/net_util.h" | 25 #include "net/base/net_util.h" |
| 26 #include "net/base/sdch_manager.h" | 26 #include "net/base/sdch_manager.h" |
| 27 #include "net/base/ssl_cert_request_info.h" | 27 #include "net/base/ssl_cert_request_info.h" |
| 28 #include "net/base/ssl_config_service.h" | 28 #include "net/base/ssl_config_service.h" |
| 29 #include "net/base/transport_security_state.h" | 29 #include "net/base/transport_security_state.h" |
| 30 #include "net/http/http_mac_signature.h" |
| 30 #include "net/http/http_request_headers.h" | 31 #include "net/http/http_request_headers.h" |
| 31 #include "net/http/http_response_headers.h" | 32 #include "net/http/http_response_headers.h" |
| 32 #include "net/http/http_response_info.h" | 33 #include "net/http/http_response_info.h" |
| 33 #include "net/http/http_transaction.h" | 34 #include "net/http/http_transaction.h" |
| 34 #include "net/http/http_transaction_factory.h" | 35 #include "net/http/http_transaction_factory.h" |
| 35 #include "net/http/http_util.h" | 36 #include "net/http/http_util.h" |
| 36 #include "net/url_request/https_prober.h" | 37 #include "net/url_request/https_prober.h" |
| 37 #include "net/url_request/url_request.h" | 38 #include "net/url_request/url_request.h" |
| 38 #include "net/url_request/url_request_context.h" | 39 #include "net/url_request/url_request_context.h" |
| 39 #include "net/url_request/url_request_error_job.h" | 40 #include "net/url_request/url_request_error_job.h" |
| 40 #include "net/url_request/url_request_redirect_job.h" | 41 #include "net/url_request/url_request_redirect_job.h" |
| 41 #include "net/url_request/url_request_throttler_header_adapter.h" | 42 #include "net/url_request/url_request_throttler_header_adapter.h" |
| 42 #include "net/url_request/url_request_throttler_manager.h" | 43 #include "net/url_request/url_request_throttler_manager.h" |
| 43 | 44 |
| 44 static const char kAvailDictionaryHeader[] = "Avail-Dictionary"; | 45 static const char kAvailDictionaryHeader[] = "Avail-Dictionary"; |
| 45 | 46 |
| 46 // When histogramming results related to SDCH and/or an SDCH latency test, the | 47 // When histogramming results related to SDCH and/or an SDCH latency test, the |
| 47 // number of packets for which we need to record arrival times so as to | 48 // number of packets for which we need to record arrival times so as to |
| 48 // calculate interpacket latencies. We currently are only looking at the | 49 // calculate interpacket latencies. We currently are only looking at the |
| 49 // first few packets, as we're monitoring the impact of the initial TCP | 50 // first few packets, as we're monitoring the impact of the initial TCP |
| 50 // congestion window on stalling of transmissions. | 51 // congestion window on stalling of transmissions. |
| 51 static const size_t kSdchPacketHistogramCount = 5; | 52 static const size_t kSdchPacketHistogramCount = 5; |
| 52 | 53 |
| 53 namespace net { | 54 namespace net { |
| 54 | 55 |
| 55 namespace { | 56 namespace { |
| 56 | 57 |
| 58 void AddAuthorizationHeader( |
| 59 const std::vector<CookieStore::CookieInfo>& cookie_infos, |
| 60 HttpRequestInfo* request_info) { |
| 61 const GURL& url = request_info->url; |
| 62 const std::string& method = request_info->method; |
| 63 std::string request_uri = HttpUtil::PathForRequest(url); |
| 64 const std::string& host = url.host(); |
| 65 int port = url.EffectiveIntPort(); |
| 66 for (size_t i = 0; i < cookie_infos.size(); ++i) { |
| 67 HttpMacSignature signature; |
| 68 if (!signature.AddStateInfo(cookie_infos[i].name, |
| 69 cookie_infos[i].mac_key, |
| 70 cookie_infos[i].mac_algorithm)) { |
| 71 continue; |
| 72 } |
| 73 if (!signature.AddHttpInfo(method, request_uri, host, port)) |
| 74 continue; |
| 75 request_info->extra_headers.SetHeader( |
| 76 HttpRequestHeaders::kAuthorization, |
| 77 signature.GenerateAuthorizationHeader()); |
| 78 return; // Only add the first valid header. |
| 79 } |
| 80 } |
| 81 |
| 57 class HTTPSProberDelegateImpl : public HTTPSProberDelegate { | 82 class HTTPSProberDelegateImpl : public HTTPSProberDelegate { |
| 58 public: | 83 public: |
| 59 HTTPSProberDelegateImpl(const std::string& host, int max_age, | 84 HTTPSProberDelegateImpl(const std::string& host, int max_age, |
| 60 bool include_subdomains, | 85 bool include_subdomains, |
| 61 TransportSecurityState* sts) | 86 TransportSecurityState* sts) |
| 62 : host_(host), | 87 : host_(host), |
| 63 max_age_(max_age), | 88 max_age_(max_age), |
| 64 include_subdomains_(include_subdomains), | 89 include_subdomains_(include_subdomains), |
| 65 sts_(sts) { } | 90 sts_(sts) { } |
| 66 | 91 |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 bool allow = true; | 458 bool allow = true; |
| 434 if (request_info_.load_flags & LOAD_DO_NOT_SEND_COOKIES || | 459 if (request_info_.load_flags & LOAD_DO_NOT_SEND_COOKIES || |
| 435 (request_->delegate() && | 460 (request_->delegate() && |
| 436 !request_->delegate()->CanGetCookies(request_))) { | 461 !request_->delegate()->CanGetCookies(request_))) { |
| 437 allow = false; | 462 allow = false; |
| 438 } | 463 } |
| 439 | 464 |
| 440 if (request_->context()->cookie_store() && allow) { | 465 if (request_->context()->cookie_store() && allow) { |
| 441 CookieOptions options; | 466 CookieOptions options; |
| 442 options.set_include_httponly(); | 467 options.set_include_httponly(); |
| 443 std::string cookies = | 468 std::string cookie_line; |
| 444 request_->context()->cookie_store()->GetCookiesWithOptions( | 469 std::vector<CookieStore::CookieInfo> cookie_infos; |
| 445 request_->url(), options); | 470 request_->context()->cookie_store()->GetCookiesWithInfo( |
| 446 if (!cookies.empty()) { | 471 request_->url(), options, &cookie_line, &cookie_infos); |
| 472 if (!cookie_line.empty()) { |
| 447 request_info_.extra_headers.SetHeader( | 473 request_info_.extra_headers.SetHeader( |
| 448 HttpRequestHeaders::kCookie, cookies); | 474 HttpRequestHeaders::kCookie, cookie_line); |
| 449 } | 475 } |
| 476 if (URLRequest::AreMacCookiesEnabled()) |
| 477 AddAuthorizationHeader(cookie_infos, &request_info_); |
| 450 } | 478 } |
| 451 // We may have been canceled within CanGetCookies. | 479 // We may have been canceled within CanGetCookies. |
| 452 if (GetStatus().is_success()) { | 480 if (GetStatus().is_success()) { |
| 453 StartTransaction(); | 481 StartTransaction(); |
| 454 } else { | 482 } else { |
| 455 NotifyCanceled(); | 483 NotifyCanceled(); |
| 456 } | 484 } |
| 457 } | 485 } |
| 458 | 486 |
| 459 void URLRequestHttpJob::SaveCookiesAndNotifyHeadersComplete() { | 487 void URLRequestHttpJob::SaveCookiesAndNotifyHeadersComplete() { |
| (...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1359 } | 1387 } |
| 1360 | 1388 |
| 1361 bool URLRequestHttpJob::IsCompressibleContent() const { | 1389 bool URLRequestHttpJob::IsCompressibleContent() const { |
| 1362 std::string mime_type; | 1390 std::string mime_type; |
| 1363 return GetMimeType(&mime_type) && | 1391 return GetMimeType(&mime_type) && |
| 1364 (IsSupportedJavascriptMimeType(mime_type.c_str()) || | 1392 (IsSupportedJavascriptMimeType(mime_type.c_str()) || |
| 1365 IsSupportedNonImageMimeType(mime_type.c_str())); | 1393 IsSupportedNonImageMimeType(mime_type.c_str())); |
| 1366 } | 1394 } |
| 1367 | 1395 |
| 1368 } // namespace net | 1396 } // namespace net |
| OLD | NEW |