From c4721e10204b2de432d3f9ba88911c4230f8a735 Mon Sep 17 00:00:00 2001 From: hagen Date: Thu, 14 Jul 2016 00:00:00 +0000 Subject: [PATCH] + HTTP.{cpp,h} : add HTTPRes::is_gzipped() --- HTTP.cpp | 12 ++++++++++++ HTTP.h | 3 +++ 2 files changed, 15 insertions(+) diff --git a/HTTP.cpp b/HTTP.cpp index 27421241..20f07448 100644 --- a/HTTP.cpp +++ b/HTTP.cpp @@ -278,6 +278,18 @@ namespace http { return false; } + bool HTTPRes::is_gzipped() { + auto it = headers.find("x-i2p-gzip"); + if (it == headers.end()) + return true; /* i2p-specific header */ + it = headers.find("Content-Encoding"); + if (it == headers.end()) + return false; /* no header */ + if (it->second.find("gzip") != std::string::npos) + return true; /* gotcha! */ + return false; + } + long int HTTPMsg::content_length() { unsigned long int length = 0; auto it = headers.find("Content-Length"); diff --git a/HTTP.h b/HTTP.h index bce55026..847cf347 100644 --- a/HTTP.h +++ b/HTTP.h @@ -118,6 +118,9 @@ namespace http { /** @brief Checks that response declared as chunked data */ bool is_chunked(); + + /** @brief Checks that response contains compressed data */ + bool is_gzipped(); }; /**