Skip to content

Commit

Permalink
Add MotD when using a broken alternate update server
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob1 committed Mar 23, 2019
1 parent e07b133 commit c7ae820
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
10 changes: 6 additions & 4 deletions src/client/Client.cpp
Expand Up @@ -656,7 +656,7 @@ RequestStatus Client::ParseServerReturn(ByteString &result, int status, bool jso
return RequestOkay;
if (status != 200)
{
lastError = String::Build("HTTP Error ", status, ": ", ByteString(http::StatusText(status)).FromUtf8());
lastError = String::Build("HTTP Error ", status, ": ", http::StatusText(status));
return RequestFailure;
}

Expand Down Expand Up @@ -686,7 +686,7 @@ RequestStatus Client::ParseServerReturn(ByteString &result, int status, bool jso
if (!strncmp(result.c_str(), "Error: ", 7))
{
status = ByteString(result.begin() + 7, result.end()).ToNumber<int>();
lastError = String::Build("HTTP Error ", status, ": ", ByteString(http::StatusText(status)).FromUtf8());
lastError = String::Build("HTTP Error ", status, ": ", http::StatusText(status));
return RequestFailure;
}
lastError = "Could not read response: " + ByteString(e.what()).FromUtf8();
Expand Down Expand Up @@ -729,6 +729,8 @@ bool Client::CheckUpdate(http::Request *updateRequest, bool checkSession)
if (status != 200)
{
//free(data);
if (usingAltUpdateServer && !checkSession)
this->messageOfTheDay = String::Build("HTTP Error ", status, " while checking for updates: ", http::StatusText(status));
}
else if(data.size())
{
Expand Down Expand Up @@ -1475,7 +1477,7 @@ SaveInfo * Client::GetSave(int saveID, int saveDate)
}
else
{
lastError = ByteString(http::StatusText(dataStatus)).FromUtf8();
lastError = http::StatusText(dataStatus);
}
return NULL;
}
Expand Down Expand Up @@ -1521,7 +1523,7 @@ std::vector<std::pair<ByteString, int> > * Client::GetTags(int start, int count,
}
else
{
lastError = ByteString(http::StatusText(dataStatus)).FromUtf8();
lastError = http::StatusText(dataStatus);
}
return tagArray;
}
Expand Down
2 changes: 1 addition & 1 deletion src/client/http/Request.cpp
Expand Up @@ -274,7 +274,7 @@ namespace http
return request->Finish(status);
}

const char *StatusText(int ret)
String StatusText(int ret)
{
switch (ret)
{
Expand Down
2 changes: 1 addition & 1 deletion src/client/http/Request.h
Expand Up @@ -72,7 +72,7 @@ namespace http
static ByteString SimpleAuth(ByteString uri, int *status, ByteString ID, ByteString session, std::map<ByteString, ByteString> post_data = std::map<ByteString, ByteString>{});
};

const char *StatusText(int code);
String StatusText(int code);

extern const long timeout;
extern ByteString proxy;
Expand Down
2 changes: 1 addition & 1 deletion src/lua/LegacyLuaAPI.cpp
Expand Up @@ -1362,7 +1362,7 @@ int luatpt_getscript(lua_State* l)
}
if (ret != 200)
{
return luaL_error(l, http::StatusText(ret));
return luaL_error(l, http::StatusText(ret).ToUtf8().c_str());
}

if (!strcmp(scriptData.c_str(), "Invalid script ID\r\n"))
Expand Down

0 comments on commit c7ae820

Please sign in to comment.