Support response data streaming and add an example file downloader.

This commit is contained in:
Chunting Gu
2019-08-08 17:12:22 +08:00
parent 3077f21549
commit 0292b4b51e
19 changed files with 370 additions and 148 deletions
+6 -2
View File
@@ -57,7 +57,11 @@ public:
// Send a request.
// Please use RequestBuilder to build the request.
ResponsePtr Request(RequestPtr request);
// If |stream| is true, the response data will be written into a temp file,
// the response body will be FileBody, and you can easily move the temp file
// to another path with FileBody::Move(). So |stream| is useful for
// downloading files (JPEG, etc.) or saving memory for huge data responses.
ResponsePtr Request(RequestPtr request, bool stream = false);
// Shortcut for GET request.
ResponsePtr Get(const std::string& url, const Strings& parameters = {},
@@ -85,7 +89,7 @@ public:
private:
void InitHeaders();
ResponsePtr Send(RequestPtr request);
ResponsePtr Send(RequestPtr request, bool stream);
private:
// Default media type for `Content-Type` header.