mirror of
https://github.com/yuzu-emu/breakpad.git
synced 2025-01-11 00:35:45 +00:00
sym_upload: Show failure if symbol server gives redirect response
Add a "response_code" parameter to Linux's HTTPUpload::SendRequest() that, if non-NULL, will be set to the response code of the HTTP request. Using that, sym_upload will print a failure message on Linux if the response code is not 200. This is in line with the change made by http://breakpad.appspot.com/77001/ for the Mac version. BUG=google-breakpad:480, chromium-os:30032 TEST=Ran "sym_upload powertop.sym http://test.webdav.org/redir-tmp/" Ran "sym_upload powertop.sym http://clients2.google.com/cr/staging_symbol" Review URL: https://breakpad.appspot.com/388002 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@968 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
parent
4191cae361
commit
d6b6959e0e
|
@ -62,7 +62,11 @@ bool HTTPUpload::SendRequest(const string &url,
|
||||||
const string &proxy_user_pwd,
|
const string &proxy_user_pwd,
|
||||||
const string &ca_certificate_file,
|
const string &ca_certificate_file,
|
||||||
string *response_body,
|
string *response_body,
|
||||||
|
long *response_code,
|
||||||
string *error_description) {
|
string *error_description) {
|
||||||
|
if (response_code != NULL)
|
||||||
|
*response_code = 0;
|
||||||
|
|
||||||
if (!CheckParameters(parameters))
|
if (!CheckParameters(parameters))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -149,6 +153,11 @@ bool HTTPUpload::SendRequest(const string &url,
|
||||||
CURLcode (*curl_easy_perform)(CURL *);
|
CURLcode (*curl_easy_perform)(CURL *);
|
||||||
*(void**) (&curl_easy_perform) = dlsym(curl_lib, "curl_easy_perform");
|
*(void**) (&curl_easy_perform) = dlsym(curl_lib, "curl_easy_perform");
|
||||||
err_code = (*curl_easy_perform)(curl);
|
err_code = (*curl_easy_perform)(curl);
|
||||||
|
if (response_code != NULL) {
|
||||||
|
CURLcode (*curl_easy_getinfo)(CURL *, CURLINFO, ...);
|
||||||
|
*(void**) (&curl_easy_getinfo) = dlsym(curl_lib, "curl_easy_getinfo");
|
||||||
|
(*curl_easy_getinfo)(curl, CURLINFO_RESPONSE_CODE, response_code);
|
||||||
|
}
|
||||||
const char* (*curl_easy_strerror)(CURLcode);
|
const char* (*curl_easy_strerror)(CURLcode);
|
||||||
*(void**) (&curl_easy_strerror) = dlsym(curl_lib, "curl_easy_strerror");
|
*(void**) (&curl_easy_strerror) = dlsym(curl_lib, "curl_easy_strerror");
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
|
|
|
@ -53,6 +53,8 @@ class HTTPUpload {
|
||||||
// Only HTTP(S) URLs are currently supported. Returns true on success.
|
// Only HTTP(S) URLs are currently supported. Returns true on success.
|
||||||
// If the request is successful and response_body is non-NULL,
|
// If the request is successful and response_body is non-NULL,
|
||||||
// the response body will be returned in response_body.
|
// the response body will be returned in response_body.
|
||||||
|
// If response_code is non-NULL, it will be set to the HTTP response code
|
||||||
|
// received (or 0 if the request failed before getting an HTTP response).
|
||||||
// If the send fails, a description of the error will be
|
// If the send fails, a description of the error will be
|
||||||
// returned in error_description.
|
// returned in error_description.
|
||||||
static bool SendRequest(const string &url,
|
static bool SendRequest(const string &url,
|
||||||
|
@ -63,6 +65,7 @@ class HTTPUpload {
|
||||||
const string &proxy_user_pwd,
|
const string &proxy_user_pwd,
|
||||||
const string &ca_certificate_file,
|
const string &ca_certificate_file,
|
||||||
string *response_body,
|
string *response_body,
|
||||||
|
long *response_code,
|
||||||
string *error_description);
|
string *error_description);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -71,6 +71,7 @@ static void Start(Options *options) {
|
||||||
options->proxy_user_pwd,
|
options->proxy_user_pwd,
|
||||||
"",
|
"",
|
||||||
&response,
|
&response,
|
||||||
|
NULL,
|
||||||
&error);
|
&error);
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
|
|
|
@ -139,6 +139,7 @@ static void Start(Options *options) {
|
||||||
parameters["code_file"] = module_parts[4];
|
parameters["code_file"] = module_parts[4];
|
||||||
parameters["debug_identifier"] = compacted_id;
|
parameters["debug_identifier"] = compacted_id;
|
||||||
std::string response, error;
|
std::string response, error;
|
||||||
|
long response_code;
|
||||||
bool success = HTTPUpload::SendRequest(options->uploadURLStr,
|
bool success = HTTPUpload::SendRequest(options->uploadURLStr,
|
||||||
parameters,
|
parameters,
|
||||||
options->symbolsPath,
|
options->symbolsPath,
|
||||||
|
@ -147,14 +148,21 @@ static void Start(Options *options) {
|
||||||
options->proxy_user_pwd,
|
options->proxy_user_pwd,
|
||||||
"",
|
"",
|
||||||
&response,
|
&response,
|
||||||
|
&response_code,
|
||||||
&error);
|
&error);
|
||||||
|
|
||||||
if (success) {
|
if (!success) {
|
||||||
printf("Successfully sent the symbol file.\n");
|
|
||||||
} else {
|
|
||||||
printf("Failed to send symbol file: %s\n", error.c_str());
|
printf("Failed to send symbol file: %s\n", error.c_str());
|
||||||
printf("Response:\n");
|
printf("Response:\n");
|
||||||
printf("%s\n", response.c_str());
|
printf("%s\n", response.c_str());
|
||||||
|
} else if (response_code == 0) {
|
||||||
|
printf("Failed to send symbol file: No response code\n");
|
||||||
|
} else if (response_code != 200) {
|
||||||
|
printf("Failed to send symbol file: Response code %ld\n", response_code);
|
||||||
|
printf("Response:\n");
|
||||||
|
printf("%s\n", response.c_str());
|
||||||
|
} else {
|
||||||
|
printf("Successfully sent the symbol file.\n");
|
||||||
}
|
}
|
||||||
options->success = success;
|
options->success = success;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue