| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium OS 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 "update_engine/libcurl_http_fetcher.h" | 5 #include "update_engine/libcurl_http_fetcher.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include <base/logging.h> | 10 #include <base/logging.h> |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 << " connection"; | 109 << " connection"; |
| 110 url_to_use = ""; // Sabotage the URL | 110 url_to_use = ""; // Sabotage the URL |
| 111 } | 111 } |
| 112 | 112 |
| 113 CHECK_EQ(curl_easy_setopt(curl_handle_, CURLOPT_URL, url_to_use.c_str()), | 113 CHECK_EQ(curl_easy_setopt(curl_handle_, CURLOPT_URL, url_to_use.c_str()), |
| 114 CURLE_OK); | 114 CURLE_OK); |
| 115 | 115 |
| 116 // If the connection drops under 10 bytes/sec for 3 minutes, reconnect. | 116 // If the connection drops under 10 bytes/sec for 3 minutes, reconnect. |
| 117 CHECK_EQ(curl_easy_setopt(curl_handle_, CURLOPT_LOW_SPEED_LIMIT, 10), | 117 CHECK_EQ(curl_easy_setopt(curl_handle_, CURLOPT_LOW_SPEED_LIMIT, 10), |
| 118 CURLE_OK); | 118 CURLE_OK); |
| 119 CHECK_EQ(curl_easy_setopt(curl_handle_, CURLOPT_LOW_SPEED_TIME, 3 * 60), | 119 // Use a smaller timeout on official builds, larger for dev. Dev users |
| 120 // want a longer timeout b/c they may be waiting on the dev server to |
| 121 // build an image. |
| 122 const int kTimeout = IsOfficialBuild() ? 90 : 3 * 60; |
| 123 CHECK_EQ(curl_easy_setopt(curl_handle_, CURLOPT_LOW_SPEED_TIME, kTimeout), |
| 120 CURLE_OK); | 124 CURLE_OK); |
| 121 | 125 |
| 122 // By default, libcurl doesn't follow redirections. Allow up to | 126 // By default, libcurl doesn't follow redirections. Allow up to |
| 123 // |kMaxRedirects| redirections. | 127 // |kMaxRedirects| redirections. |
| 124 CHECK_EQ(curl_easy_setopt(curl_handle_, CURLOPT_FOLLOWLOCATION, 1), CURLE_OK); | 128 CHECK_EQ(curl_easy_setopt(curl_handle_, CURLOPT_FOLLOWLOCATION, 1), CURLE_OK); |
| 125 CHECK_EQ(curl_easy_setopt(curl_handle_, CURLOPT_MAXREDIRS, kMaxRedirects), | 129 CHECK_EQ(curl_easy_setopt(curl_handle_, CURLOPT_MAXREDIRS, kMaxRedirects), |
| 126 CURLE_OK); | 130 CURLE_OK); |
| 127 | 131 |
| 128 // Security lock-down in official builds: makes sure that peer certificate | 132 // Security lock-down in official builds: makes sure that peer certificate |
| 129 // verification is enabled, restricts the set of trusted certificates, | 133 // verification is enabled, restricts the set of trusted certificates, |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 void LibcurlHttpFetcher::GetHttpResponseCode() { | 457 void LibcurlHttpFetcher::GetHttpResponseCode() { |
| 454 long http_response_code = 0; | 458 long http_response_code = 0; |
| 455 if (curl_easy_getinfo(curl_handle_, | 459 if (curl_easy_getinfo(curl_handle_, |
| 456 CURLINFO_RESPONSE_CODE, | 460 CURLINFO_RESPONSE_CODE, |
| 457 &http_response_code) == CURLE_OK) { | 461 &http_response_code) == CURLE_OK) { |
| 458 http_response_code_ = static_cast<int>(http_response_code); | 462 http_response_code_ = static_cast<int>(http_response_code); |
| 459 } | 463 } |
| 460 } | 464 } |
| 461 | 465 |
| 462 } // namespace chromeos_update_engine | 466 } // namespace chromeos_update_engine |
| OLD | NEW |