mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2026-10-23 04:21:37 +00:00
open torrents web page in another tab. Don't return Content-Typo for unknown type
This commit is contained in:
1 parent
f946ed6a12
commit
2ff3cd6eee
2 files changed
+8
-4
No files matched your search
@@ -1255,8 +1255,8 @@ namespace http {
|
||||
std::string jsRedir = "this.href = location.protocol + '//' + location.hostname + ':' + " + std::to_string(rpcPort) + " + '" + webPath + "/web/'";
|
||||
|
||||
s << "<a href='http://localhost:" << rpcPort << webPath << "/web/' "
|
||||
<< "onmouseover=\"" << jsRedir << "\" "
|
||||
<< "onclick=\"" << jsRedir << "\">"
|
||||
<< "onmouseover=\"" << jsRedir << "\" target=\"_blank\" rel=\"noopener noreferrer\""
|
||||
<< "onclick=\"" << jsRedir << "\" target=\"_blank\" rel=\"noopener noreferrer\">"
|
||||
<< " | Web Panel</a>";
|
||||
}
|
||||
s << "</div>\r\n"<< std::endl;
|
||||
|
||||
@@ -931,11 +931,14 @@ namespace torrents
|
||||
{ ".swf", { "application/x-shockwave-flash", false } }
|
||||
};
|
||||
|
||||
std::string contentType ("text/html; charset=utf-8");
|
||||
std::string contentType ("");
|
||||
auto filePath = std::filesystem::path (i2p::fs::GetDataDir ()) / "torrents" / "web";
|
||||
std::string target {req.target ()};
|
||||
if (target.empty () || target.back() == '/')
|
||||
{
|
||||
filePath /= "index.html";
|
||||
contentType = "text/html; charset=utf-8";
|
||||
}
|
||||
else
|
||||
{
|
||||
std::filesystem::path urlPath (target);
|
||||
@@ -995,7 +998,8 @@ namespace torrents
|
||||
m_WebResponse->result (boost::beast::http::status::ok);
|
||||
m_WebResponse->version(11);
|
||||
m_WebResponse->set (boost::beast::http::field::server, "i2pd torrents web");
|
||||
m_WebResponse->set (boost::beast::http::field::content_type, contentType);
|
||||
if (contentType.length())
|
||||
m_WebResponse->set (boost::beast::http::field::content_type, contentType);
|
||||
m_WebResponse->body () = std::move (body);
|
||||
boost::beast::http::async_write (m_Socket, *m_WebResponse,
|
||||
[s = shared_from_this ()](const boost::system::error_code& ecode, size_t bytes_transferred)
|
||||
|
||||
Reference in new issue
Block a user