aboutsummaryrefslogtreecommitdiff
path: root/src/common/windows/http_upload.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/windows/http_upload.h')
-rw-r--r--src/common/windows/http_upload.h97
1 files changed, 47 insertions, 50 deletions
diff --git a/src/common/windows/http_upload.h b/src/common/windows/http_upload.h
index f8d48cb1..57e526e3 100644
--- a/src/common/windows/http_upload.h
+++ b/src/common/windows/http_upload.h
@@ -42,18 +42,41 @@
#include <wininet.h>
#include <map>
-#include <string>
-#include <vector>
namespace google_breakpad {
using std::string;
using std::wstring;
using std::map;
-using std::vector;
class HTTPUpload {
public:
+ // Sends a PUT request containing the data in |path| to the given
+ // URL.
+ // 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 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).
+ static bool SendPutRequest(
+ const wstring& url,
+ const wstring& path,
+ int* timeout_ms,
+ wstring* response_body,
+ int* response_code);
+
+ // Sends a GET request to the given URL.
+ // 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 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).
+ static bool SendGetRequest(
+ const wstring& url,
+ int* timeout_ms,
+ wstring* response_body,
+ int* response_code);
+
// 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
@@ -65,55 +88,29 @@ class HTTPUpload {
// 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).
- static bool SendRequest(const wstring &url,
- const map<wstring, wstring> &parameters,
- const map<wstring, wstring> &files,
- int *timeout,
- wstring *response_body,
- int *response_code);
+ static bool SendMultipartPostRequest(
+ const wstring& url,
+ const map<wstring, wstring>& parameters,
+ const map<wstring, wstring>& files,
+ int *timeout_ms,
+ wstring *response_body,
+ int *response_code);
+
+ // Sends a POST request, with the body set to |body|, to the given URL.
+ // 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 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).
+ static bool SendSimplePostRequest(
+ const wstring& url,
+ const wstring& body,
+ const wstring& content_type,
+ int *timeout_ms,
+ wstring *response_body,
+ int *response_code);
private:
- class AutoInternetHandle;
-
- // Retrieves the HTTP response. If NULL is passed in for response,
- // this merely checks (via the return value) that we were successfully
- // able to retrieve exactly as many bytes of content in the response as
- // were specified in the Content-Length header.
- static bool ReadResponse(HINTERNET request, wstring* response);
-
- // Generates a new multipart boundary for a POST request
- static wstring GenerateMultipartBoundary();
-
- // 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,
- // 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 &boundary,
- string *request_body);
-
- // Fills the supplied vector with the contents of filename.
- static bool GetFileContents(const wstring &filename, vector<char> *contents);
-
- // Converts a UTF8 string to UTF16.
- static wstring UTF8ToWide(const string &utf8);
-
- // Converts a UTF16 string to UTF8.
- static string WideToUTF8(const wstring &wide) {
- return WideToMBCP(wide, CP_UTF8);
- }
-
- // Converts a UTF16 string to specified code page.
- static string WideToMBCP(const wstring &wide, unsigned int cp);
-
- // Checks that the given list of parameters has only printable
- // ASCII characters in the parameter name, and does not contain
- // any quote (") characters. Returns true if so.
- static bool CheckParameters(const map<wstring, wstring> &parameters);
-
// No instances of this class should be created.
// Disallow all constructors, destructors, and operator=.
HTTPUpload();