From ac2888d2d68a418d8e048b61c769d018b16e2afd Mon Sep 17 00:00:00 2001 From: orignal Date: Fri, 9 Oct 2026 08:11:05 -0400 Subject: [PATCH] x-i2p-gzip shoudln't trigger gzipped if not requested explicitly --- libi2pd/HTTP.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/libi2pd/HTTP.cpp b/libi2pd/HTTP.cpp index 3e087c29..1bccebdd 100644 --- a/libi2pd/HTTP.cpp +++ b/libi2pd/HTTP.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include "util.h" #include "Base.h" #include "HTTP.h" @@ -444,10 +445,17 @@ namespace http auto it = headers.find("Content-Encoding"); if (it == headers.end()) return false; /* no header */ - if (it->second.find("gzip") != std::string::npos) - return true; /* gotcha! */ - if (includingI2PGzip && it->second.find("x-i2p-gzip") != std::string::npos) - return true; + + std::vector encodingDirectives; + boost::split (encodingDirectives, it->second, boost::is_any_of(","), boost::token_compress_on); + for (auto& directive: encodingDirectives) + { + boost::algorithm::trim (directive); + if (directive == "gzip") + return true; /* gotcha! */ + if (includingI2PGzip && directive == "x-i2p-gzip") + return true; + } return false; }