From d47d8d22a319713f8d8e817fdb05bd93a2e02428 Mon Sep 17 00:00:00 2001 From: orignal Date: Fri, 28 Jul 2017 11:16:42 -0400 Subject: [PATCH] removed all Accept-* headers but Accept-Encoding --- libi2pd/HTTP.cpp | 4 ++-- libi2pd/HTTP.h | 12 ++++++++---- libi2pd_client/HTTPProxy.cpp | 6 +++--- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/libi2pd/HTTP.cpp b/libi2pd/HTTP.cpp index 77922686..cc6e724b 100644 --- a/libi2pd/HTTP.cpp +++ b/libi2pd/HTTP.cpp @@ -293,11 +293,11 @@ namespace http { } } - void HTTPReq::RemoveHeader (const std::string& name) + void HTTPReq::RemoveHeader (const std::string& name, const std::string& exempt) { for (auto it = headers.begin (); it != headers.end ();) { - if (!it->first.compare(0, name.length (), name)) + if (!it->first.compare(0, name.length (), name) && it->first != exempt) it = headers.erase (it); else it++; diff --git a/libi2pd/HTTP.h b/libi2pd/HTTP.h index 251d98bc..198362f5 100644 --- a/libi2pd/HTTP.h +++ b/libi2pd/HTTP.h @@ -16,14 +16,17 @@ #include #include -namespace i2p { -namespace http { +namespace i2p +{ +namespace http +{ const char CRLF[] = "\r\n"; /**< HTTP line terminator */ const char HTTP_EOH[] = "\r\n\r\n"; /**< HTTP end-of-headers mark */ extern const std::vector HTTP_METHODS; /**< list of valid HTTP methods */ extern const std::vector HTTP_VERSIONS; /**< list of valid HTTP versions */ - struct URL { + struct URL + { std::string schema; std::string user; std::string pass; @@ -90,7 +93,8 @@ namespace http { void AddHeader (const std::string& name, const std::string& value); void UpdateHeader (const std::string& name, const std::string& value); - void RemoveHeader (const std::string& name); + void RemoveHeader (const std::string& name, const std::string& exempt); // remove all headers starting with name, but exempt + void RemoveHeader (const std::string& name) { RemoveHeader (name, ""); }; std::string GetHeader (const std::string& name) const; }; diff --git a/libi2pd_client/HTTPProxy.cpp b/libi2pd_client/HTTPProxy.cpp index d2d472c8..50a45e99 100644 --- a/libi2pd_client/HTTPProxy.cpp +++ b/libi2pd_client/HTTPProxy.cpp @@ -202,11 +202,11 @@ namespace proxy { /* drop common headers */ req.RemoveHeader ("Referer"); req.RemoveHeader("Via"); - req.RemoveHeader("Forwarded"); - req.RemoveHeader("Accept-Language"); // TODO: should exclude all Accept-*, but Accept-Encoding + req.RemoveHeader("Forwarded"); + req.RemoveHeader("Accept-", "Accept-Encoding"); // Accept-*, but Accept-Encoding /* drop proxy-disclosing headers */ req.RemoveHeader("X-Forwarded"); - req.RemoveHeader("Proxy-"); + req.RemoveHeader("Proxy-"); // Proxy-* /* replace headers */ req.UpdateHeader("User-Agent", "MYOB/6.66 (AN/ON)"); /* add headers */