aboutsummaryrefslogtreecommitdiff
path: root/src/common/windows
diff options
context:
space:
mode:
authormark@chromium.org <mark@chromium.org>2014-09-03 13:40:40 +0000
committermark@chromium.org <mark@chromium.org>2014-09-03 13:40:40 +0000
commita58de86bcd085c035f3e7103b6c15fee72b97753 (patch)
treea96b5e6f783b761c15c0cdef8afcfc1c52a6ec73 /src/common/windows
parentAdding possibility for client to upload the file (diff)
downloadbreakpad-a58de86bcd085c035f3e7103b6c15fee72b97753.tar.xz
Back out trunk r1367.
Compile error: https://bugzilla.mozilla.org/show_bug.cgi?id=1048091#c15 Review URL: https://breakpad.appspot.com/9694002 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1369 4c0a9323-5329-0410-9bdc-e9ce6186880e
Diffstat (limited to 'src/common/windows')
-rw-r--r--src/common/windows/http_upload.cc56
-rw-r--r--src/common/windows/http_upload.h14
2 files changed, 36 insertions, 34 deletions
diff --git a/src/common/windows/http_upload.cc b/src/common/windows/http_upload.cc
index d9c4048f..838185b7 100644
--- a/src/common/windows/http_upload.cc
+++ b/src/common/windows/http_upload.cc
@@ -64,7 +64,8 @@ class HTTPUpload::AutoInternetHandle {
// static
bool HTTPUpload::SendRequest(const wstring &url,
const map<wstring, wstring> &parameters,
- const map<wstring, wstring> &files,
+ const wstring &upload_file,
+ const wstring &file_part_name,
int *timeout,
wstring *response_body,
int *response_code) {
@@ -142,7 +143,8 @@ bool HTTPUpload::SendRequest(const wstring &url,
HTTP_ADDREQ_FLAG_ADD);
string request_body;
- if (!GenerateRequestBody(parameters, files, boundary, &request_body)) {
+ if (!GenerateRequestBody(parameters, upload_file,
+ file_part_name, boundary, &request_body)) {
return false;
}
@@ -266,9 +268,15 @@ wstring HTTPUpload::GenerateRequestHeader(const wstring &boundary) {
// static
bool HTTPUpload::GenerateRequestBody(const map<wstring, wstring> &parameters,
- const map<wstring, wstring> &files,
+ const wstring &upload_file,
+ const wstring &file_part_name,
const wstring &boundary,
string *request_body) {
+ vector<char> contents;
+ if (!GetFileContents(upload_file, &contents)) {
+ return false;
+ }
+
string boundary_str = WideToUTF8(boundary);
if (boundary_str.empty()) {
return false;
@@ -285,36 +293,28 @@ bool HTTPUpload::GenerateRequestBody(const map<wstring, wstring> &parameters,
WideToUTF8(pos->second) + "\r\n");
}
- for (map<wstring, wstring>::const_iterator pos = files.begin();
- pos != files.end(); ++pos) {
- vector<char> contents;
- if (!GetFileContents(pos->second, &contents)) {
- return false;
- }
-
- // Now append the upload files as a binary (octet-stream) part
- string filename_utf8 = WideToUTF8(pos->second);
- if (filename_utf8.empty()) {
- return false;
- }
+ // Now append the upload file as a binary (octet-stream) part
+ string filename_utf8 = WideToUTF8(upload_file);
+ if (filename_utf8.empty()) {
+ return false;
+ }
- string file_part_name_utf8 = WideToUTF8(pos->first);
- if (file_part_name_utf8.empty()) {
- return false;
- }
+ string file_part_name_utf8 = WideToUTF8(file_part_name);
+ if (file_part_name_utf8.empty()) {
+ return false;
+ }
- request_body->append("--" + boundary_str + "\r\n");
- request_body->append("Content-Disposition: form-data; "
- "name=\"" + file_part_name_utf8 + "\"; "
- "filename=\"" + filename_utf8 + "\"\r\n");
- request_body->append("Content-Type: application/octet-stream\r\n");
- request_body->append("\r\n");
+ request_body->append("--" + boundary_str + "\r\n");
+ request_body->append("Content-Disposition: form-data; "
+ "name=\"" + file_part_name_utf8 + "\"; "
+ "filename=\"" + filename_utf8 + "\"\r\n");
+ request_body->append("Content-Type: application/octet-stream\r\n");
+ request_body->append("\r\n");
- if (!contents.empty()) {
+ if (!contents.empty()) {
request_body->append(&(contents[0]), contents.size());
- }
- request_body->append("\r\n");
}
+ request_body->append("\r\n");
request_body->append("--" + boundary_str + "--\r\n");
return true;
}
diff --git a/src/common/windows/http_upload.h b/src/common/windows/http_upload.h
index c2707102..0594cde3 100644
--- a/src/common/windows/http_upload.h
+++ b/src/common/windows/http_upload.h
@@ -54,9 +54,9 @@ using std::vector;
class HTTPUpload {
public:
- // Sends the given sets of parameters and files as a multipart POST
- // request to the given URL.
- // Each key in |files| is the name of the file part of the request
+ // Sends the given set of parameters, along with the contents of
+ // upload_file, as a multipart POST request to the given URL.
+ // file_part_name contains the name of the file part of the request
// (i.e. it corresponds to the name= attribute on an <input type="file">.
// Parameter names must contain only printable ASCII characters,
// and may not contain a quote (") character.
@@ -67,7 +67,8 @@ class HTTPUpload {
// received (or 0 if the request failed before getting an HTTP response).
static bool SendRequest(const wstring &url,
const map<wstring, wstring> &parameters,
- const map<wstring, wstring> &files,
+ const wstring &upload_file,
+ const wstring &file_part_name,
int *timeout,
wstring *response_body,
int *response_code);
@@ -87,11 +88,12 @@ class HTTPUpload {
// Generates a HTTP request header for a multipart form submit.
static wstring GenerateRequestHeader(const wstring &boundary);
- // Given a set of parameters, a set of upload files, and a file part name,
+ // Given a set of parameters, an upload filename, and a file part name,
// generates a multipart request body string with these parameters
// and minidump contents. Returns true on success.
static bool GenerateRequestBody(const map<wstring, wstring> &parameters,
- const map<wstring, wstring> &files,
+ const wstring &upload_file,
+ const wstring &file_part_name,
const wstring &boundary,
string *request_body);