From 73725774dc8ce7feaeb8dbeb4e55f6e73160df1b Mon Sep 17 00:00:00 2001 From: EinMByte Date: Sun, 27 Sep 2015 16:55:39 +0200 Subject: [PATCH] Minor bugfixes for windows. --- client/HTTPServer.cpp | 6 +++--- core/util/HTTP.cpp | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/client/HTTPServer.cpp b/client/HTTPServer.cpp index 6f0bf309..994f9b13 100644 --- a/client/HTTPServer.cpp +++ b/client/HTTPServer.cpp @@ -11,7 +11,7 @@ namespace util { HTTPConnection::HTTPConnection(boost::asio::ip::tcp::socket* socket, std::shared_ptr session) - : m_Socket(socket), m_BufferLen(0), m_Session(session) + : m_Socket(socket), m_BufferLen(0), m_Request(), m_Reply(), m_Session(session) { } @@ -128,7 +128,7 @@ std::string HTTPConnection::GetFileContents(const std::string& filename, bool pr const std::string address_str = address.string(); - std::ifstream ifs(address_str); + std::ifstream ifs(address_str, std::ios_base::in | std::ios_base::binary); if(e || !ifs || !isAllowed(address_str)) throw std::runtime_error("Cannot load " + address_str + "."); @@ -154,7 +154,7 @@ void HTTPConnection::HandleRequest() try { m_Reply = i2p::util::http::Response(200, GetFileContents(uri, true)); - m_Reply.setHeader("Content-Type", i2p::util::http::getMimeType(uri)); + m_Reply.setHeader("Content-Type", i2p::util::http::getMimeType(uri) + "; charset=UTF-8"); SendReply(); } catch(const std::runtime_error&) { // Cannot open the file for some reason, send 404 diff --git a/core/util/HTTP.cpp b/core/util/HTTP.cpp index 020d9776..ea8c9dff 100644 --- a/core/util/HTTP.cpp +++ b/core/util/HTTP.cpp @@ -207,7 +207,8 @@ std::string preprocessContent(const std::string& content, const std::string& pat // Read the contents of the included file std::ifstream ifs( - boost::filesystem::canonical(directory / std::string(match[1]), e).string() + boost::filesystem::canonical(directory / std::string(match[1]), e).string(), + std::ios_base::in | std::ios_base::binary ); if(e || !ifs) continue;