Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: libcurl_http_fetcher.cc

Issue 3161041: AU: Support redirects. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: reorder headers again Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « libcurl_http_fetcher.h ('k') | test_http_server.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include <algorithm> 6 #include <algorithm>
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 using std::max; 9 using std::max;
10 using std::make_pair; 10 using std::make_pair;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 CHECK_EQ(curl_easy_setopt(curl_handle_, CURLOPT_WRITEFUNCTION, 54 CHECK_EQ(curl_easy_setopt(curl_handle_, CURLOPT_WRITEFUNCTION,
55 StaticLibcurlWrite), CURLE_OK); 55 StaticLibcurlWrite), CURLE_OK);
56 CHECK_EQ(curl_easy_setopt(curl_handle_, CURLOPT_URL, url_.c_str()), CURLE_OK); 56 CHECK_EQ(curl_easy_setopt(curl_handle_, CURLOPT_URL, url_.c_str()), CURLE_OK);
57 57
58 // If the connection drops under 10 bytes/sec for 3 minutes, reconnect. 58 // If the connection drops under 10 bytes/sec for 3 minutes, reconnect.
59 CHECK_EQ(curl_easy_setopt(curl_handle_, CURLOPT_LOW_SPEED_LIMIT, 10), 59 CHECK_EQ(curl_easy_setopt(curl_handle_, CURLOPT_LOW_SPEED_LIMIT, 10),
60 CURLE_OK); 60 CURLE_OK);
61 CHECK_EQ(curl_easy_setopt(curl_handle_, CURLOPT_LOW_SPEED_TIME, 3 * 60), 61 CHECK_EQ(curl_easy_setopt(curl_handle_, CURLOPT_LOW_SPEED_TIME, 3 * 60),
62 CURLE_OK); 62 CURLE_OK);
63 63
64 // By default, libcurl doesn't follow redirections. Allow up to
65 // |kMaxRedirects| redirections.
66 CHECK_EQ(curl_easy_setopt(curl_handle_, CURLOPT_FOLLOWLOCATION, 1),
67 CURLE_OK);
68 CHECK_EQ(curl_easy_setopt(curl_handle_, CURLOPT_MAXREDIRS, kMaxRedirects),
69 CURLE_OK);
70
64 CHECK_EQ(curl_multi_add_handle(curl_multi_handle_, curl_handle_), CURLM_OK); 71 CHECK_EQ(curl_multi_add_handle(curl_multi_handle_, curl_handle_), CURLM_OK);
65 transfer_in_progress_ = true; 72 transfer_in_progress_ = true;
66 } 73 }
67 74
68 // Begins the transfer, which must not have already been started. 75 // Begins the transfer, which must not have already been started.
69 void LibcurlHttpFetcher::BeginTransfer(const std::string& url) { 76 void LibcurlHttpFetcher::BeginTransfer(const std::string& url) {
70 transfer_size_ = -1; 77 transfer_size_ = -1;
71 bytes_downloaded_ = 0; 78 bytes_downloaded_ = 0;
72 resume_offset_ = 0; 79 resume_offset_ = 0;
73 retry_count_ = 0; 80 retry_count_ = 0;
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 curl_handle_ = NULL; 280 curl_handle_ = NULL;
274 } 281 }
275 if (curl_multi_handle_) { 282 if (curl_multi_handle_) {
276 CHECK_EQ(curl_multi_cleanup(curl_multi_handle_), CURLM_OK); 283 CHECK_EQ(curl_multi_cleanup(curl_multi_handle_), CURLM_OK);
277 curl_multi_handle_ = NULL; 284 curl_multi_handle_ = NULL;
278 } 285 }
279 transfer_in_progress_ = false; 286 transfer_in_progress_ = false;
280 } 287 }
281 288
282 } // namespace chromeos_update_engine 289 } // namespace chromeos_update_engine
OLDNEW
« no previous file with comments | « libcurl_http_fetcher.h ('k') | test_http_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698