From 28b4474ae4fbdbb843267084234dc62ffe7b1d77 Mon Sep 17 00:00:00 2001 From: Riasan Date: Fri, 12 May 2017 19:29:10 +0200 Subject: [PATCH 1/2] Changed: Add a new gui window web_lua_action --HG-- branch : develop --- .../data/gamedev/interfaces_v3/guild.xml | 166 ++++++++++++++++++ 1 file changed, 166 insertions(+) diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/guild.xml b/code/ryzom/client/data/gamedev/interfaces_v3/guild.xml index 78099815f..454e131c5 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/guild.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/guild.xml @@ -1294,4 +1294,170 @@ + + + + + + + + + + + + + + + + + + + + + From 6c01ded28d9893be8b11ef91709c637f62fc85ff Mon Sep 17 00:00:00 2001 From: Nimetu Date: Sun, 14 May 2017 01:03:49 +0300 Subject: [PATCH 2/2] Fixed: Redirect for image requests --HG-- branch : develop --- code/nel/include/nel/gui/group_html.h | 3 +- code/nel/src/gui/group_html.cpp | 53 ++++++++++++++++++++++----- 2 files changed, 46 insertions(+), 10 deletions(-) diff --git a/code/nel/include/nel/gui/group_html.h b/code/nel/include/nel/gui/group_html.h index ead873497..42da5da20 100644 --- a/code/nel/include/nel/gui/group_html.h +++ b/code/nel/include/nel/gui/group_html.h @@ -821,7 +821,7 @@ namespace NLGUI { public: CDataDownload(const std::string &u, const std::string &d, TDataType t, CViewBase *i, const std::string &s, const std::string &m, const CStyleParams &style = CStyleParams()) - : data(NULL), fp(NULL), url(u), dest(d), type(t), luaScript(s), md5sum(m) + : data(NULL), fp(NULL), url(u), dest(d), type(t), luaScript(s), md5sum(m), redirects(0) { if (t == ImgType) imgs.push_back(CDataImageDownload(i, style)); } @@ -833,6 +833,7 @@ namespace NLGUI std::string luaScript; std::string md5sum; TDataType type; + uint32 redirects; FILE *fp; std::vector imgs; }; diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index 79dfa77f1..3895f9521 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -651,17 +651,52 @@ namespace NLGUI string tmpfile = it->dest + ".tmp"; if(res != CURLE_OK || r < 200 || r >= 300 || (!it->md5sum.empty() && (it->md5sum != getMD5(tmpfile).toString()))) { - NLMISC::CFile::deleteFile(tmpfile.c_str()); - - // 304 Not Modified - if (res == CURLE_OK && r == 304) + if (it->redirects < DEFAULT_RYZOM_REDIRECT_LIMIT && ((r >= 301 && r <= 303) || r == 307 || r == 308)) { - CHttpCacheObject obj; - obj.Expires = it->data->getExpires(); - obj.Etag = it->data->getEtag(); - obj.LastModified = it->data->getLastModified(); + std::string location(it->data->getLocationHeader()); + if (!location.empty()) + { + CUrlParser uri(location); + if (!uri.isAbsolute()) + { + uri.inherit(it->url); + location = uri.toString(); + } - CHttpCache::getInstance()->store(it->dest, obj); + it->url = location; + it->fp = NULL; + + // release CCurlWWWData + delete it->data; + it->data = NULL; + + it->redirects++; + #ifdef LOG_DL + nlwarning("Redirect '%s'", location.c_str()); + #endif + // keep the request in queue + continue; + } + else + nlwarning("Redirected to empty url '%s'", it->url.c_str()); + } + else + { + if (it->redirects >= DEFAULT_RYZOM_REDIRECT_LIMIT) + nlwarning("Redirect limit reached for '%s'", it->url.c_str()); + + NLMISC::CFile::deleteFile(tmpfile.c_str()); + + // 304 Not Modified + if (res == CURLE_OK && r == 304) + { + CHttpCacheObject obj; + obj.Expires = it->data->getExpires(); + obj.Etag = it->data->getEtag(); + obj.LastModified = it->data->getLastModified(); + + CHttpCache::getInstance()->store(it->dest, obj); + } } } else