add Accept() for Accept header to request builder

This commit is contained in:
Chunting Gu
2020-08-10 09:48:30 +08:00
parent b334e359d7
commit 39ade6df4f
6 changed files with 42 additions and 14 deletions
+8 -2
View File
@@ -13,6 +13,12 @@ ClientSession::ClientSession(int timeout, bool ssl_verify,
InitHeaders();
}
void ClientSession::Accept(const std::string& content_types) {
if (!content_types.empty()) {
headers_.Set(headers::kAccept, content_types);
}
}
void ClientSession::Auth(const std::string& type,
const std::string& credentials) {
headers_.Set(headers::kAuthorization, type + " " + credentials);
@@ -74,14 +80,14 @@ void ClientSession::InitHeaders() {
// Simply put, "deflate" is not recommended for HTTP 1.1 encoding.
// (https://www.zlib.net/zlib_faq.html#faq39)
headers_.Set(kAccept, "*/*");
#if WEBCC_ENABLE_GZIP
headers_.Set(kAcceptEncoding, "gzip, deflate");
#else
headers_.Set(kAcceptEncoding, "identity");
#endif // WEBCC_ENABLE_GZIP
headers_.Set(kAccept, "*/*");
headers_.Set(kConnection, "Keep-Alive");
}