Add an option to disable GZIP.

This commit is contained in:
Chunting Gu
2019-04-22 14:43:46 +08:00
parent 88f5ae3c91
commit 2a868c4dc1
20 changed files with 130 additions and 74 deletions
+18 -2
View File
@@ -5,7 +5,10 @@
#include "webcc/logger.h"
#include "webcc/message.h"
#include "webcc/utility.h"
#include "webcc/zlib_wrapper.h"
#if WEBCC_ENABLE_GZIP
#include "webcc/gzip.h"
#endif
namespace webcc {
@@ -323,16 +326,29 @@ bool Parser::Finish() {
return true;
}
#if WEBCC_ENABLE_GZIP
LOG_INFO("Decompress the HTTP content...");
std::string decompressed;
if (!Decompress(content_, &decompressed)) {
if (!gzip::Decompress(content_, &decompressed)) {
LOG_ERRO("Cannot decompress the HTTP content!");
return false;
}
message_->SetContent(std::move(decompressed), false);
return true;
#else
LOG_WARN("Compressed HTTP content remains untouched.");
message_->SetContent(std::move(content_), false);
return true;
#endif // WEBCC_ENABLE_GZIP
}
void Parser::AppendContent(const char* data, std::size_t count) {