From feff0b300f1032862f6474142bd1bf95f457af98 Mon Sep 17 00:00:00 2001 From: "ted.mielczarek" Date: Fri, 2 Nov 2007 12:22:35 +0000 Subject: [PATCH] Issue 221 - HTTPUpload::SendRequest should provide error code or error description to callers. r=Liu Li git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@228 4c0a9323-5329-0410-9bdc-e9ce6186880e --- src/common/linux/http_upload.cc | 7 ++++++- src/common/linux/http_upload.h | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/common/linux/http_upload.cc b/src/common/linux/http_upload.cc index 8556cfc0..4896edd0 100644 --- a/src/common/linux/http_upload.cc +++ b/src/common/linux/http_upload.cc @@ -61,12 +61,15 @@ bool HTTPUpload::SendRequest(const string &url, const string &file_part_name, const string &proxy, const string &proxy_user_pwd, - string *response_body) { + string *response_body, + string *error_description) { if (!CheckParameters(parameters)) return false; CURL *curl = curl_easy_init(); CURLcode err_code = CURLE_OK; + if (error_description != NULL) + *error_description = "No Error"; if (curl) { curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); @@ -114,6 +117,8 @@ bool HTTPUpload::SendRequest(const string &url, url.c_str(), curl_easy_strerror(err_code)); #endif + if (error_description != NULL) + *error_description = curl_easy_strerror(err_code); if (curl != NULL) curl_easy_cleanup(curl); diff --git a/src/common/linux/http_upload.h b/src/common/linux/http_upload.h index 040fd2de..fa6ad12c 100644 --- a/src/common/linux/http_upload.h +++ b/src/common/linux/http_upload.h @@ -53,13 +53,16 @@ class HTTPUpload { // Only HTTP(S) URLs are currently supported. Returns true on success. // If the request is successful and response_body is non-NULL, // the response body will be returned in response_body. + // If the send fails, a description of the error will be + // returned in error_description. static bool SendRequest(const string &url, const map ¶meters, const string &upload_file, const string &file_part_name, const string &proxy, const string &proxy_user_pwd, - string *response_body); + string *response_body, + string *error_description); private: // Checks that the given list of parameters has only printable