summaryrefslogtreecommitdiff
path: root/indra/viewer_components/updater/llupdatechecker.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/viewer_components/updater/llupdatechecker.cpp')
-rwxr-xr-xindra/viewer_components/updater/llupdatechecker.cpp89
1 files changed, 42 insertions, 47 deletions
diff --git a/indra/viewer_components/updater/llupdatechecker.cpp b/indra/viewer_components/updater/llupdatechecker.cpp
index 8da4f88905..e889f83aa9 100755
--- a/indra/viewer_components/updater/llupdatechecker.cpp
+++ b/indra/viewer_components/updater/llupdatechecker.cpp
@@ -26,10 +26,10 @@
#include "linden_common.h"
#include <stdexcept>
#include <boost/format.hpp>
-#include "llhttpclient.h"
#include "llsd.h"
#include "llupdatechecker.h"
#include "lluri.h"
+#include "llcorehttputil.h"
#if LL_DARWIN
#include <CoreServices/CoreServices.h>
#endif
@@ -53,15 +53,12 @@ public:
// LLUpdateChecker
//-----------------------------------------------------------------------------
-
-
LLUpdateChecker::LLUpdateChecker(LLUpdateChecker::Client & client):
mImplementation(new LLUpdateChecker::Implementation(client))
{
; // No op.
}
-
void LLUpdateChecker::checkVersion(std::string const & urlBase,
std::string const & channel,
std::string const & version,
@@ -74,11 +71,8 @@ void LLUpdateChecker::checkVersion(std::string const & urlBase,
}
-
// LLUpdateChecker::Implementation
//-----------------------------------------------------------------------------
-
-
const char * LLUpdateChecker::Implementation::sProtocolVersion = "v1.1";
@@ -121,57 +115,58 @@ void LLUpdateChecker::Implementation::checkVersion(std::string const & urlBase,
std::string checkUrl = buildUrl(urlBase, channel, version, platform, platform_version, uniqueid, willing_to_test);
LL_INFOS("UpdaterService") << "checking for updates at " << checkUrl << LL_ENDL;
-
- mHttpClient.get(checkUrl, this);
- }
- else
- {
- LL_WARNS("UpdaterService") << "attempting to restart a check when one is in progress; ignored" << LL_ENDL;
- }
-}
-void LLUpdateChecker::Implementation::httpCompleted()
-{
- mInProgress = false;
+ LLCoros::instance().launch("LLUpdateChecker::Implementation::checkVersionCoro",
+ boost::bind(&Implementation::checkVersionCoro, this, checkUrl));
- S32 status = getStatus();
- const LLSD& content = getContent();
- const std::string& reason = getReason();
- if(status != 200)
- {
- std::string server_error;
- if ( content.has("error_code") )
- {
- server_error += content["error_code"].asString();
- }
- if ( content.has("error_text") )
- {
- server_error += server_error.empty() ? "" : ": ";
- server_error += content["error_text"].asString();
- }
-
- LL_WARNS("UpdaterService") << "response error " << status
- << " " << reason
- << " (" << server_error << ")"
- << LL_ENDL;
- mClient.error(reason);
}
else
{
- mClient.response(content);
+ LL_WARNS("UpdaterService") << "attempting to restart a check when one is in progress; ignored" << LL_ENDL;
}
}
-
-void LLUpdateChecker::Implementation::httpFailure()
+void LLUpdateChecker::Implementation::checkVersionCoro(std::string url)
{
- const std::string& reason = getReason();
- mInProgress = false;
- LL_WARNS("UpdaterService") << "update check failed; " << reason << LL_ENDL;
- mClient.error(reason);
+ LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
+ LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t
+ httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("checkVersionCoro", httpPolicy));
+ LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest);
+
+ LL_INFOS("checkVersionCoro") << "Getting update information from " << url << LL_ENDL;
+
+ LLSD result = httpAdapter->getAndYield(httpRequest, url);
+
+ LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS];
+ LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults);
+
+ mInProgress = false;
+
+ if (status != LLCore::HttpStatus(HTTP_OK))
+ {
+ std::string server_error;
+ if (result.has("error_code"))
+ {
+ server_error += result["error_code"].asString();
+ }
+ if (result.has("error_text"))
+ {
+ server_error += server_error.empty() ? "" : ": ";
+ server_error += result["error_text"].asString();
+ }
+
+ LL_WARNS("UpdaterService") << "response error " << status.getStatus()
+ << " " << status.toString()
+ << " (" << server_error << ")"
+ << LL_ENDL;
+ mClient.error(status.toString());
+ return;
+ }
+
+ result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS);
+ mClient.response(result);
}
-
std::string LLUpdateChecker::Implementation::buildUrl(std::string const & urlBase,
std::string const & channel,
std::string const & version,