accept-encoding default to identity even if gzip is enabled.

This commit is contained in:
Chunting Gu
2020-09-14 13:25:04 +08:00
parent a827f4cfe2
commit 7a09d47e8f
6 changed files with 118 additions and 89 deletions
+14 -5
View File
@@ -124,6 +124,13 @@ public:
return Header(headers::kAccept, content_types);
}
#if WEBCC_ENABLE_GZIP
// Accept Gzip compressed response data or not.
RequestBuilder& AcceptGzip(bool gzip = true);
#endif // WEBCC_ENABLE_GZIP
RequestBuilder& Body(const std::string& data) {
body_.reset(new StringBody{ data, false });
return *this;
@@ -173,10 +180,17 @@ public:
RequestBuilder& Date();
#if WEBCC_ENABLE_GZIP
// Compress the body data (only for string body).
// NOTE:
// Most servers don't support compressed requests.
// Even the requests module from Python doesn't have a built-in support.
// See: https://github.com/kennethreitz/requests/issues/1753
RequestBuilder& Gzip(bool gzip = true) {
gzip_ = gzip;
return *this;
}
#endif // WEBCC_ENABLE_GZIP
private:
@@ -207,11 +221,6 @@ private:
bool keep_alive_ = true;
#if WEBCC_ENABLE_GZIP
// Compress the body data (only for string body).
// NOTE:
// Most servers don't support compressed requests.
// Even the requests module from Python doesn't have a built-in support.
// See: https://github.com/kennethreitz/requests/issues/1753
bool gzip_ = false;
#endif // WEBCC_ENABLE_GZIP
};