aboutsummaryrefslogtreecommitdiff
path: root/src/common/windows
diff options
context:
space:
mode:
authorted.mielczarek@gmail.com <ted.mielczarek@gmail.com@4c0a9323-5329-0410-9bdc-e9ce6186880e>2010-12-15 16:19:32 +0000
committerted.mielczarek@gmail.com <ted.mielczarek@gmail.com@4c0a9323-5329-0410-9bdc-e9ce6186880e>2010-12-15 16:19:32 +0000
commit7405ecd04629d759e6525c134ea375aa3aad83c0 (patch)
treec68b1c75b878230e7df3009d9aa4d37d2b0ea362 /src/common/windows
parentAdd some unit tests for the mac MinidumpGenerator (diff)
downloadbreakpad-7405ecd04629d759e6525c134ea375aa3aad83c0.tar.xz
allow uploading zero-byte files in HTTPUpload
R=mark at http://breakpad.appspot.com/243001/show git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@743 4c0a9323-5329-0410-9bdc-e9ce6186880e
Diffstat (limited to 'src/common/windows')
-rw-r--r--src/common/windows/http_upload.cc13
-rw-r--r--src/common/windows/http_upload.h2
2 files changed, 7 insertions, 8 deletions
diff --git a/src/common/windows/http_upload.cc b/src/common/windows/http_upload.cc
index a6879799..ddf61f7f 100644
--- a/src/common/windows/http_upload.cc
+++ b/src/common/windows/http_upload.cc
@@ -274,8 +274,7 @@ bool HTTPUpload::GenerateRequestBody(const map<wstring, wstring> &parameters,
const wstring &boundary,
string *request_body) {
vector<char> contents;
- GetFileContents(upload_file, &contents);
- if (contents.empty()) {
+ if (!GetFileContents(upload_file, &contents)) {
return false;
}
@@ -322,7 +321,7 @@ bool HTTPUpload::GenerateRequestBody(const map<wstring, wstring> &parameters,
}
// static
-void HTTPUpload::GetFileContents(const wstring &filename,
+bool HTTPUpload::GetFileContents(const wstring &filename,
vector<char> *contents) {
// The "open" method on pre-MSVC8 ifstream implementations doesn't accept a
// wchar_t* filename, so use _wfopen directly in that case. For VC8 and
@@ -339,13 +338,13 @@ void HTTPUpload::GetFileContents(const wstring &filename,
std::streamoff length = file.tellg();
contents->resize(length);
if (length != 0) {
- file.seekg(0, ios::beg);
- file.read(&((*contents)[0]), length);
+ file.seekg(0, ios::beg);
+ file.read(&((*contents)[0]), length);
}
file.close();
- } else {
- contents->clear();
+ return true;
}
+ return false;
}
// static
diff --git a/src/common/windows/http_upload.h b/src/common/windows/http_upload.h
index f7c69f16..8a17aab1 100644
--- a/src/common/windows/http_upload.h
+++ b/src/common/windows/http_upload.h
@@ -98,7 +98,7 @@ class HTTPUpload {
string *request_body);
// Fills the supplied vector with the contents of filename.
- static void GetFileContents(const wstring &filename, vector<char> *contents);
+ static bool GetFileContents(const wstring &filename, vector<char> *contents);
// Converts a UTF8 string to UTF16.
static wstring UTF8ToWide(const string &utf8);