From 06510d5e6ab51a9d13e191a23374cfb8a285b1ec Mon Sep 17 00:00:00 2001 From: orignal Date: Mon, 6 Jul 2026 21:14:41 -0400 Subject: [PATCH] made to_string const --- libi2pd/HTTP.cpp | 7 ++++--- libi2pd/HTTP.h | 8 +++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/libi2pd/HTTP.cpp b/libi2pd/HTTP.cpp index 08b0a8e4..036c1dde 100644 --- a/libi2pd/HTTP.cpp +++ b/libi2pd/HTTP.cpp @@ -230,7 +230,8 @@ namespace http return true; } - std::string URL::to_string() { + std::string URL::to_string() const + { std::string out = ""; if (schema != "") { out = schema + "://"; @@ -349,7 +350,7 @@ namespace http return eoh + HTTP_EOH.length(); } - void HTTPReq::write(std::ostream & o) + void HTTPReq::write(std::ostream & o) const { o << method << " " << uri << " " << version << CRLF; for (auto & h : headers) @@ -357,7 +358,7 @@ namespace http o << CRLF; } - std::string HTTPReq::to_string() + std::string HTTPReq::to_string() const { std::stringstream ss; write(ss); diff --git a/libi2pd/HTTP.h b/libi2pd/HTTP.h index 11e9df6e..ab6b4166 100644 --- a/libi2pd/HTTP.h +++ b/libi2pd/HTTP.h @@ -68,7 +68,7 @@ namespace http * @brief Serialize URL structure to url * @note Returns relative url if schema if empty, absolute url otherwise */ - std::string to_string (); + std::string to_string () const; /** * @brief return true if the host is inside i2p @@ -107,8 +107,8 @@ namespace http int parse(std::string_view buf); /** @brief Serialize HTTP request to string */ - std::string to_string(); - void write(std::ostream & o); + std::string to_string() const; + void write(std::ostream & o) const; void AddHeader (const std::string& name, const std::string& value); void UpdateHeader (const std::string& name, const std::string& value); @@ -151,8 +151,6 @@ namespace http */ std::string to_string(); - void write(std::ostream & o); - /** @brief Checks that response declared as chunked data */ bool is_chunked() const ;