Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Turn RequestBroker::Get/SaveUserInfoAsync into a request derived from…
… Download Also move everything http_ into Download and DownloadManager and nuke RequestBroker.
- Loading branch information
Showing
31 changed files
with
260 additions
and
1,200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include "APIRequest.h" | ||
|
||
#include "client/Client.h" | ||
|
||
namespace http | ||
{ | ||
APIRequest::APIRequest(ByteString url) : Download(url) | ||
{ | ||
User user = Client::Ref().GetAuthUser(); | ||
AuthHeaders(ByteString::Build(user.UserID), user.SessionID); | ||
} | ||
|
||
APIRequest::~APIRequest() | ||
{ | ||
} | ||
|
||
APIRequest::Result APIRequest::Finish() | ||
{ | ||
Result result; | ||
try | ||
{ | ||
ByteString data = Download::Finish(&result.status); | ||
Client::Ref().ParseServerReturn(data, result.status, true); | ||
if (result.status == 200 && data.size()) | ||
{ | ||
std::istringstream dataStream(data); | ||
Json::Value objDocument; | ||
dataStream >> objDocument; | ||
result.document = std::unique_ptr<Json::Value>(new Json::Value(objDocument)); | ||
} | ||
} | ||
catch (std::exception & e) | ||
{ | ||
} | ||
return result; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#ifndef APIREQUEST2_H | ||
#define APIREQUEST2_H | ||
|
||
#include "Download.h" | ||
#include "common/String.h" | ||
#include "json/json.h" | ||
|
||
#include <memory> | ||
#include <map> | ||
|
||
namespace http | ||
{ | ||
class APIRequest : public Download | ||
{ | ||
public: | ||
struct Result | ||
{ | ||
int status; | ||
std::unique_ptr<Json::Value> document; | ||
}; | ||
|
||
APIRequest(ByteString url); | ||
virtual ~APIRequest(); | ||
|
||
Result Finish(); | ||
}; | ||
} | ||
|
||
#endif // APIREQUEST2_H | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.