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

Unified Diff: src/libcurl_http_fetcher.cc

Issue 4203001: cashew: libcurl http fetcher: use default CA certificate path (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/cashew.git
Patch Set: Created 10 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/libcurl_http_fetcher.h ('k') | src/service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/libcurl_http_fetcher.cc
diff --git a/src/libcurl_http_fetcher.cc b/src/libcurl_http_fetcher.cc
index 89514274a496113bbec42b15841e3ab5bca27864..55affc9c9ba79dd547b4b55334d781792c2d59ca 100644
--- a/src/libcurl_http_fetcher.cc
+++ b/src/libcurl_http_fetcher.cc
@@ -21,7 +21,6 @@ namespace cashew {
namespace {
const int kMaxRetriesCount = 20;
-const char kCACertificatesPath[] = "/usr/share/cashew/ca-certificates";
}
LibcurlHttpFetcher::~LibcurlHttpFetcher() {
@@ -73,11 +72,8 @@ void LibcurlHttpFetcher::ResumeTransfer(const std::string& url) {
CHECK_EQ(curl_easy_setopt(curl_handle_, CURLOPT_MAXREDIRS, kMaxRedirects),
CURLE_OK);
- // Makes sure that peer certificate verification is enabled and restricts the
- // set of trusted certificates.
+ // Makes sure that peer certificate verification is enabled
CHECK_EQ(curl_easy_setopt(curl_handle_, CURLOPT_SSL_VERIFYPEER, 1), CURLE_OK);
- CHECK_EQ(curl_easy_setopt(curl_handle_, CURLOPT_CAPATH, kCACertificatesPath),
- CURLE_OK);
CHECK_EQ(curl_multi_add_handle(curl_multi_handle_, curl_handle_), CURLM_OK);
transfer_in_progress_ = true;
@@ -111,15 +107,12 @@ void LibcurlHttpFetcher::CurlPerformOnce() {
retcode = curl_multi_perform(curl_multi_handle_, &running_handles);
}
if (0 == running_handles) {
- long http_response_code = 0; // NOLINT
- if (curl_easy_getinfo(curl_handle_,
- CURLINFO_RESPONSE_CODE,
- &http_response_code) == CURLE_OK) {
- LOG(INFO) << "HTTP response code: " << http_response_code;
+ GetHttpResponseCode();
+ if (http_response_code_) {
+ LOG(INFO) << "HTTP response code: " << http_response_code_;
} else {
- LOG(ERROR) << "Unable to get http response code.";
+ LOG(WARNING) << "Unable to get http response code.";
}
- http_response_code_ = static_cast<int>(http_response_code);
// we're done!
CleanUp();
@@ -141,9 +134,9 @@ void LibcurlHttpFetcher::CurlPerformOnce() {
return;
} else {
if (delegate_) {
- // success is when http_response_code is 2xx
- bool success = (http_response_code >= 200) &&
- (http_response_code < 300);
+ // success is when http_response_code_ is 2xx
+ bool success = (http_response_code_ >= 200) &&
+ (http_response_code_ < 300);
delegate_->TransferComplete(this, success);
}
}
@@ -154,6 +147,7 @@ void LibcurlHttpFetcher::CurlPerformOnce() {
}
size_t LibcurlHttpFetcher::LibcurlWrite(void *ptr, size_t size, size_t nmemb) {
+ GetHttpResponseCode();
DLOG(INFO) << "LibcurlWrite";
{
double transfer_size_double;
@@ -306,4 +300,17 @@ void LibcurlHttpFetcher::CleanUp() {
transfer_in_progress_ = false;
}
+void LibcurlHttpFetcher::GetHttpResponseCode() {
+ long http_response_code = 0; // NOLINT
+ CURLcode result = curl_easy_getinfo(curl_handle_,
+ CURLINFO_RESPONSE_CODE,
+ &http_response_code);
+ if (result == CURLE_OK) {
+ http_response_code_ = static_cast<int>(http_response_code);
+ } else {
+ DLOG(WARNING) << "GetHttpResponseCode: curl_easy_getinfo failed: "
+ << curl_easy_strerror(result);
+ }
+}
+
} // namespace cashew
« no previous file with comments | « src/libcurl_http_fetcher.h ('k') | src/service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698