From b31f52e332cdae586f02e39228c4e229d07bc4ea Mon Sep 17 00:00:00 2001 From: R4SAS Date: Wed, 25 Jan 2023 08:54:45 +0000 Subject: [PATCH] [http] keep query even if it was empty (closes #1844) Signed-off-by: R4SAS --- libi2pd/HTTP.cpp | 5 ++++- libi2pd/HTTP.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/libi2pd/HTTP.cpp b/libi2pd/HTTP.cpp index 8791eadb..b8d7e8c3 100644 --- a/libi2pd/HTTP.cpp +++ b/libi2pd/HTTP.cpp @@ -160,6 +160,7 @@ namespace http return true; } else if (url.at(pos_c) == '?') { /* found query part */ + hasquery = true; path = url.substr(pos_p, pos_c - pos_p); pos_p = pos_c + 1; pos_c = url.find('#', pos_p); @@ -218,8 +219,10 @@ namespace http } } out += path; + if (hasquery) // add query even if it was empty + out += "?"; if (query != "") - out += "?" + query; + out += query; if (frag != "") out += "#" + frag; return out; diff --git a/libi2pd/HTTP.h b/libi2pd/HTTP.h index 9445a01a..046eebb9 100644 --- a/libi2pd/HTTP.h +++ b/libi2pd/HTTP.h @@ -33,6 +33,7 @@ namespace http std::string host; unsigned short int port; std::string path; + bool hasquery; std::string query; std::string frag;