mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-31 04:44:13 +00:00
Minor bugfixes for windows.
This commit is contained in:
parent
c9080f9f72
commit
73725774dc
@ -11,7 +11,7 @@ namespace util {
|
||||
|
||||
HTTPConnection::HTTPConnection(boost::asio::ip::tcp::socket* socket,
|
||||
std::shared_ptr<client::i2pcontrol::I2PControlSession> 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
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user