Show reload link when curl fails to open connection to website

feature/develop-atys
Nimetu 4 years ago
parent 5abdccfd63
commit 1e465b6cff

@ -118,6 +118,9 @@ namespace NLGUI
// Browse error // Browse error
void browseError (const char *msg); void browseError (const char *msg);
// Error message with html content
void browseErrorHtml(const std::string &html);
bool isBrowsing(); bool isBrowsing();
// Update coords // Update coords

@ -2262,6 +2262,17 @@ namespace NLGUI
invalidateCoords(); invalidateCoords();
} }
void CGroupHTML::browseErrorHtml(const std::string &html)
{
releaseDownloads();
removeContent();
renderHtmlString(html);
updateRefreshButton();
invalidateCoords();
}
// *************************************************************************** // ***************************************************************************
bool CGroupHTML::isBrowsing() bool CGroupHTML::isBrowsing()
@ -3586,11 +3597,22 @@ namespace NLGUI
{ {
if (!success) if (!success)
{ {
CUrlParser uri(_CurlWWW->Url);
// potentially unwanted chars
std::string url = _CurlWWW->Url;
url = strFindReplaceAll(url, string("<"), string("%3C"));
url = strFindReplaceAll(url, string(">"), string("%3E"));
url = strFindReplaceAll(url, string("\""), string("%22"));
url = strFindReplaceAll(url, string("'"), string("%27"));
std::string err; std::string err;
err = "Connection failed with cURL error: "; err = "<html><head><title>cURL error</title></head><body>";
err += "<h1>Connection failed with cURL error</h1>";
err += error; err += error;
err += "\nURL '" + _CurlWWW->Url + "'"; err += "<hr>(" + uri.scheme + "://" + uri.host + ") <a href=\"" + url + "\">reload</a>";
browseError(err.c_str()); err += "</body></html>";
browseErrorHtml(err);
return; return;
} }

Loading…
Cancel
Save