mirror of
https://git.suyu.dev/suyu/breakpad.git
synced 2026-01-11 00:48:05 +01:00
Port new symbol upload API to Windows symupload tool.
- CL for Linux change, including new documentation for API, at: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1422400/3 Change-Id: I579744fec74c64757b8bc31de63d7a07ef9a0f1f Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1487982 Reviewed-by: Ivan Penkov <ivanpe@chromium.org>
This commit is contained in:
parent
756daa536a
commit
548ca6e382
6 changed files with 888 additions and 420 deletions
|
|
@ -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> ¶meters,
|
||||
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> ¶meters,
|
||||
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> ¶meters);
|
||||
|
||||
// No instances of this class should be created.
|
||||
// Disallow all constructors, destructors, and operator=.
|
||||
HTTPUpload();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue