aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormmentovai <mmentovai@4c0a9323-5329-0410-9bdc-e9ce6186880e>2006-10-19 21:48:51 +0000
committermmentovai <mmentovai@4c0a9323-5329-0410-9bdc-e9ce6186880e>2006-10-19 21:48:51 +0000
commit5afd60b067a65920ba2e4705ccea71b880cc1607 (patch)
treef65b277e8c4d2f17d924f0f1706bb797beed0e4e /src
parentReduce calls to SymbolSupplier::GetSymbolFile() (#48). (diff)
downloadbreakpad-5afd60b067a65920ba2e4705ccea71b880cc1607.tar.xz
Improvements for Windows client/tool-side code. r=bryner
- Allow Windows sender to use https (#41). - HTTPUpload not proxy-friendly (#46). - Check http status codes (sort of #44). - Allow symupload to work with versionless files (prints a warning, server may still reject). http://groups.google.com/group/airbag-dev/browse_thread/thread/5a12a72dffc5999c git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@41 4c0a9323-5329-0410-9bdc-e9ce6186880e
Diffstat (limited to 'src')
-rw-r--r--src/common/windows/http_upload.cc30
-rw-r--r--src/tools/windows/symupload/symupload.cc16
2 files changed, 32 insertions, 14 deletions
diff --git a/src/common/windows/http_upload.cc b/src/common/windows/http_upload.cc
index 52bf46b3..587ac36f 100644
--- a/src/common/windows/http_upload.cc
+++ b/src/common/windows/http_upload.cc
@@ -83,12 +83,15 @@ bool HTTPUpload::SendRequest(const wstring &url,
0, &components)) {
return false;
}
- if (wcscmp(scheme, L"http") != 0) {
+ bool secure = false;
+ if (wcscmp(scheme, L"https") == 0) {
+ secure = true;
+ } else if (wcscmp(scheme, L"http") != 0) {
return false;
}
AutoInternetHandle internet(InternetOpen(kUserAgent,
- INTERNET_OPEN_TYPE_DIRECT,
+ INTERNET_OPEN_TYPE_PRECONFIG,
NULL, // proxy name
NULL, // proxy bypass
0)); // flags
@@ -108,13 +111,14 @@ bool HTTPUpload::SendRequest(const wstring &url,
return false;
}
+ DWORD http_open_flags = secure ? INTERNET_FLAG_SECURE : 0;
AutoInternetHandle request(HttpOpenRequest(connection.get(),
L"POST",
path,
NULL, // version
NULL, // referer
NULL, // agent type
- 0, // flags
+ http_open_flags,
NULL)); // context
if (!request.get()) {
return false;
@@ -130,10 +134,22 @@ bool HTTPUpload::SendRequest(const wstring &url,
GenerateRequestBody(parameters, upload_file,
file_part_name, boundary, &request_body);
- // The explicit comparison to TRUE avoids a warning (C4800).
- return (HttpSendRequest(request.get(), NULL, 0,
- const_cast<char *>(request_body.data()),
- static_cast<DWORD>(request_body.size())) == TRUE);
+ if (!HttpSendRequest(request.get(), NULL, 0,
+ const_cast<char *>(request_body.data()),
+ static_cast<DWORD>(request_body.size()))) {
+ return false;
+ }
+
+ // The server indicates a successful upload with HTTP status 200.
+ wchar_t http_status[4];
+ DWORD http_status_size = sizeof(http_status);
+ if (!HttpQueryInfo(request.get(), HTTP_QUERY_STATUS_CODE,
+ static_cast<LPVOID>(&http_status), &http_status_size,
+ 0)) {
+ return false;
+ }
+
+ return (wcscmp(http_status, L"200") == 0);
}
// static
diff --git a/src/tools/windows/symupload/symupload.cc b/src/tools/windows/symupload/symupload.cc
index 7b530d0f..e5c74664 100644
--- a/src/tools/windows/symupload/symupload.cc
+++ b/src/tools/windows/symupload/symupload.cc
@@ -148,12 +148,6 @@ int wmain(int argc, wchar_t *argv[]) {
const wchar_t *module = argv[1], *url = argv[2];
wstring module_basename = GetBaseName(module);
- wstring file_version;
- if (!GetFileVersionString(module, &file_version)) {
- fwprintf(stderr, L"Could not get file version for %s\n", module);
- return 1;
- }
-
wstring symbol_file, module_guid;
if (!DumpSymbolsToTempFile(module, &symbol_file, &module_guid)) {
fwprintf(stderr, L"Could not get symbol data from %s\n", module);
@@ -162,9 +156,17 @@ int wmain(int argc, wchar_t *argv[]) {
map<wstring, wstring> parameters;
parameters[L"module"] = module_basename;
- parameters[L"version"] = file_version;
parameters[L"guid"] = module_guid;
+ // Don't make a missing version a hard error. Issue a warning, and let the
+ // server decide whether to reject files without versions.
+ wstring file_version;
+ if (GetFileVersionString(module, &file_version)) {
+ parameters[L"version"] = file_version;
+ } else {
+ fwprintf(stderr, L"Warning: Could not get file version for %s\n", module);
+ }
+
bool success = HTTPUpload::SendRequest(url, parameters,
symbol_file, L"symbol_file");
_wunlink(symbol_file.c_str());