Rename Download* to Request* and move HTTP stuff inside src/client/http

This commit is contained in:
Tamás Bálint Misius 2019-03-07 14:33:19 +01:00 committed by jacob1
parent 1864a8649d
commit 30c7f6ded7
30 changed files with 129 additions and 132 deletions

View File

@ -51,8 +51,6 @@
#include "gui/interface/Keys.h"
#include "gui/Style.h"
#include "client/HTTP.h"
using namespace std;
#define INCLUDE_SYSWM

View File

@ -43,8 +43,8 @@
#include "client/UserInfo.h"
#include "gui/preview/Comment.h"
#include "ClientListener.h"
#include "client/Download.h"
#include "client/DownloadManager.h"
#include "client/http/Request.h"
#include "client/http/RequestManager.h"
#include "json/json.h"
@ -111,7 +111,7 @@ void Client::Initialise(ByteString proxyString)
update_finish();
}
http::DownloadManager::Ref().Initialise(proxyString);
http::RequestManager::Ref().Initialise(proxyString);
//Read stamps library
std::ifstream stampsLib;
@ -128,7 +128,7 @@ void Client::Initialise(ByteString proxyString)
stampsLib.close();
//Begin version check
versionCheckRequest = new http::Download("http://" SERVER "/Startup.json");
versionCheckRequest = new http::Request("http://" SERVER "/Startup.json");
if (authUser.UserID)
{
@ -138,7 +138,7 @@ void Client::Initialise(ByteString proxyString)
#ifdef UPDATESERVER
// use an alternate update server
alternateVersionCheckRequest = new http::Download("http://" UPDATESERVER "/Startup.json");
alternateVersionCheckRequest = new http::Request("http://" UPDATESERVER "/Startup.json");
usingAltUpdateServer = true;
if (authUser.UserID)
{
@ -718,7 +718,7 @@ void Client::Tick()
}
}
bool Client::CheckUpdate(http::Download *updateRequest, bool checkSession)
bool Client::CheckUpdate(http::Request *updateRequest, bool checkSession)
{
//Check status on version check request
if (updateRequest->CheckDone())
@ -913,7 +913,7 @@ void Client::WritePrefs()
void Client::Shutdown()
{
http::DownloadManager::Ref().Shutdown();
http::RequestManager::Ref().Shutdown();
//Save config
WritePrefs();
@ -976,7 +976,7 @@ RequestStatus Client::UploadSave(SaveInfo & save)
}
#endif
data = http::Download::SimpleAuth("http://" SERVER "/Save.api", &dataStatus, userID, authUser.SessionID, {
data = http::Request::SimpleAuth("http://" SERVER "/Save.api", &dataStatus, userID, authUser.SessionID, {
{ "Name", save.GetName().ToUtf8() },
{ "Description", save.GetDescription().ToUtf8() },
{ "Data:save.bin", ByteString(gameData, gameData + gameDataLength) },
@ -1172,7 +1172,7 @@ RequestStatus Client::ExecVote(int saveID, int direction)
{
ByteString saveIDText = ByteString::Build(saveID);
ByteString userIDText = ByteString::Build(authUser.UserID);
data = http::Download::SimpleAuth("http://" SERVER "/Vote.api", &dataStatus, userIDText, authUser.SessionID, {
data = http::Request::SimpleAuth("http://" SERVER "/Vote.api", &dataStatus, userIDText, authUser.SessionID, {
{ "ID", saveIDText },
{ "Action", direction == 1 ? "Up" : "Down" },
});
@ -1198,7 +1198,7 @@ unsigned char * Client::GetSaveData(int saveID, int saveDate, int & dataLength)
else
urlStr = ByteString::Build("http://", STATICSERVER, "/", saveID, ".cps");
data = http::Download::Simple(urlStr, &dataStatus);
data = http::Request::Simple(urlStr, &dataStatus);
// will always return failure
ParseServerReturn(data, dataStatus, false);
@ -1244,7 +1244,7 @@ LoginStatus Client::Login(ByteString username, ByteString password, User & user)
ByteString data;
int dataStatus;
data = http::Download::Simple("http://" SERVER "/Login.json", &dataStatus, {
data = http::Request::Simple("http://" SERVER "/Login.json", &dataStatus, {
{ "Username", username },
{ "Hash", totalHash },
});
@ -1304,7 +1304,7 @@ RequestStatus Client::DeleteSave(int saveID)
if(authUser.UserID)
{
ByteString userID = ByteString::Build(authUser.UserID);
data = http::Download::SimpleAuth(url, &dataStatus, userID, authUser.SessionID);
data = http::Request::SimpleAuth(url, &dataStatus, userID, authUser.SessionID);
}
else
{
@ -1324,7 +1324,7 @@ RequestStatus Client::AddComment(int saveID, String comment)
if(authUser.UserID)
{
ByteString userID = ByteString::Build(authUser.UserID);
data = http::Download::SimpleAuth(url, &dataStatus, userID, authUser.SessionID, {
data = http::Request::SimpleAuth(url, &dataStatus, userID, authUser.SessionID, {
{ "Comment", comment.ToUtf8() },
});
}
@ -1349,7 +1349,7 @@ RequestStatus Client::FavouriteSave(int saveID, bool favourite)
if(authUser.UserID)
{
ByteString userID = ByteString::Build(authUser.UserID);
data = http::Download::SimpleAuth(urlStream.Build(), &dataStatus, userID, authUser.SessionID);
data = http::Request::SimpleAuth(urlStream.Build(), &dataStatus, userID, authUser.SessionID);
}
else
{
@ -1369,7 +1369,7 @@ RequestStatus Client::ReportSave(int saveID, String message)
if(authUser.UserID)
{
ByteString userID = ByteString::Build(authUser.UserID);
data = http::Download::SimpleAuth(url, &dataStatus, userID, authUser.SessionID, {
data = http::Request::SimpleAuth(url, &dataStatus, userID, authUser.SessionID, {
{ "Reason", message.ToUtf8() },
});
}
@ -1391,7 +1391,7 @@ RequestStatus Client::UnpublishSave(int saveID)
if(authUser.UserID)
{
ByteString userID = ByteString::Build(authUser.UserID);
data = http::Download::SimpleAuth(url, &dataStatus, userID, authUser.SessionID);
data = http::Request::SimpleAuth(url, &dataStatus, userID, authUser.SessionID);
}
else
{
@ -1411,7 +1411,7 @@ RequestStatus Client::PublishSave(int saveID)
if (authUser.UserID)
{
ByteString userID = ByteString::Build(authUser.UserID);
data = http::Download::SimpleAuth(url, &dataStatus, userID, authUser.SessionID, {
data = http::Request::SimpleAuth(url, &dataStatus, userID, authUser.SessionID, {
{ "ActionPublish", "bagels" },
});
}
@ -1439,11 +1439,11 @@ SaveInfo * Client::GetSave(int saveID, int saveDate)
{
ByteString userID = ByteString::Build(authUser.UserID);
data = http::Download::SimpleAuth(urlStream.Build(), &dataStatus, userID, authUser.SessionID);
data = http::Request::SimpleAuth(urlStream.Build(), &dataStatus, userID, authUser.SessionID);
}
else
{
data = http::Download::Simple(urlStream.Build(), &dataStatus);
data = http::Request::Simple(urlStream.Build(), &dataStatus);
}
if(dataStatus == 200 && data.size())
{
@ -1511,7 +1511,7 @@ std::vector<std::pair<ByteString, int> > * Client::GetTags(int start, int count,
urlStream << format::URLEncode(query.ToUtf8());
}
data = http::Download::Simple(urlStream.Build(), &dataStatus);
data = http::Request::Simple(urlStream.Build(), &dataStatus);
if(dataStatus == 200 && data.size())
{
try
@ -1569,11 +1569,11 @@ std::vector<SaveInfo*> * Client::SearchSaves(int start, int count, String query,
if(authUser.UserID)
{
ByteString userID = ByteString::Build(authUser.UserID);
data = http::Download::SimpleAuth(urlStream.Build(), &dataStatus, userID, authUser.SessionID);
data = http::Request::SimpleAuth(urlStream.Build(), &dataStatus, userID, authUser.SessionID);
}
else
{
data = http::Download::Simple(urlStream.Build(), &dataStatus);
data = http::Request::Simple(urlStream.Build(), &dataStatus);
}
ParseServerReturn(data, dataStatus, true);
if (dataStatus == 200 && data.size())
@ -1621,7 +1621,7 @@ std::list<ByteString> * Client::RemoveTag(int saveID, ByteString tag)
if(authUser.UserID)
{
ByteString userID = ByteString::Build(authUser.UserID);
data = http::Download::SimpleAuth(url, &dataStatus, userID, authUser.SessionID);
data = http::Request::SimpleAuth(url, &dataStatus, userID, authUser.SessionID);
}
else
{
@ -1660,7 +1660,7 @@ std::list<ByteString> * Client::AddTag(int saveID, ByteString tag)
if(authUser.UserID)
{
ByteString userID = ByteString::Build(authUser.UserID);
data = http::Download::SimpleAuth(url, &dataStatus, userID, authUser.SessionID);
data = http::Request::SimpleAuth(url, &dataStatus, userID, authUser.SessionID);
}
else
{

View File

@ -48,15 +48,15 @@ class RequestListener;
class ClientListener;
namespace http
{
class Download;
class Request;
}
class Client: public Singleton<Client> {
private:
String messageOfTheDay;
std::vector<std::pair<String, ByteString> > serverNotifications;
http::Download *versionCheckRequest;
http::Download *alternateVersionCheckRequest;
http::Request *versionCheckRequest;
http::Request *alternateVersionCheckRequest;
bool usingAltUpdateServer;
bool updateAvailable;
UpdateInfo updateInfo;
@ -167,7 +167,7 @@ public:
}
RequestStatus ParseServerReturn(ByteString &result, int status, bool json);
void Tick();
bool CheckUpdate(http::Download *updateRequest, bool checkSession);
bool CheckUpdate(http::Request *updateRequest, bool checkSession);
void Shutdown();
// preferences functions

View File

@ -4,7 +4,7 @@
namespace http
{
APIRequest::APIRequest(ByteString url) : Download(url)
APIRequest::APIRequest(ByteString url) : Request(url)
{
User user = Client::Ref().GetAuthUser();
AuthHeaders(ByteString::Build(user.UserID), user.SessionID);
@ -19,7 +19,7 @@ namespace http
Result result;
try
{
ByteString data = Download::Finish(&result.status);
ByteString data = Request::Finish(&result.status);
Client::Ref().ParseServerReturn(data, result.status, true);
if (result.status == 200 && data.size())
{

View File

@ -1,7 +1,7 @@
#ifndef APIREQUEST2_H
#define APIREQUEST2_H
#include "Download.h"
#include "Request.h"
#include "common/String.h"
#include "json/json.h"
@ -10,7 +10,7 @@
namespace http
{
class APIRequest : public Download
class APIRequest : public Request
{
public:
struct Result

View File

@ -1,11 +1,11 @@
#ifndef GETUSERINFOREQUEST2_H
#define GETUSERINFOREQUEST2_H
#include "Download.h"
#include "Request.h"
#include "common/String.h"
#include "json/json.h"
#include "client/Client.h"
#include "client/APIRequest.h"
#include "APIRequest.h"
#include <memory>
#include <map>

View File

@ -51,7 +51,7 @@
#include "Config.h"
#include "Misc.h"
#include "HTTP.h"
#include "MD5.h"
#include "../MD5.h"
#include "Platform.h"
#ifdef WIN
@ -979,7 +979,7 @@ ByteString FindBoundary(std::map<ByteString, ByteString> parts, ByteString bound
// Generates a MIME multipart message to be used in POST requests
// see https://en.wikipedia.org/wiki/MIME#Multipart_messages
// this function used in Download class, and eventually all http requests
// this function used in Request class, and eventually all http requests
ByteString GetMultipartMessage(std::map<ByteString, ByteString> parts, ByteString boundary)
{
ByteStringBuilder data;

View File

@ -7,7 +7,7 @@
namespace http
{
ImageRequest::ImageRequest(ByteString url, int width, int height) :
Download(url),
Request(url),
Width(width),
Height(height)
{
@ -19,7 +19,7 @@ namespace http
std::unique_ptr<VideoBuffer> ImageRequest::Finish()
{
ByteString data = Download::Finish(nullptr);
ByteString data = Request::Finish(nullptr);
std::unique_ptr<VideoBuffer> vb;
if (data.size())
{

View File

@ -1,7 +1,7 @@
#ifndef IMAGEREQUEST2_H
#define IMAGEREQUEST2_H
#include "Download.h"
#include "Request.h"
#include "common/String.h"
#include <memory>
@ -9,7 +9,7 @@
class VideoBuffer;
namespace http
{
class ImageRequest : public Download
class ImageRequest : public Request
{
int Width, Height;

View File

@ -1,12 +1,12 @@
#include <cstdlib>
#include "Download.h"
#include "DownloadManager.h"
#include "Request.h"
#include "RequestManager.h"
#include "HTTP.h"
#include "Platform.h"
namespace http
{
Download::Download(ByteString uri_, bool keepAlive):
Request::Request(ByteString uri_, bool keepAlive):
http(NULL),
keepAlive(keepAlive),
downloadData(NULL),
@ -21,11 +21,11 @@ Download::Download(ByteString uri_, bool keepAlive):
downloadStarted(false)
{
uri = ByteString(uri_);
DownloadManager::Ref().AddDownload(this);
RequestManager::Ref().AddDownload(this);
}
// called by download thread itself if download was canceled
Download::~Download()
Request::~Request()
{
if (http && (keepAlive || downloadCanceled))
http_async_req_close(http);
@ -34,12 +34,12 @@ Download::~Download()
}
// add post data to a request
void Download::AddPostData(std::map<ByteString, ByteString> data)
void Request::AddPostData(std::map<ByteString, ByteString> data)
{
postDataBoundary = FindBoundary(data, "");
postData = GetMultipartMessage(data, postDataBoundary);
}
void Download::AddPostData(std::pair<ByteString, ByteString> data)
void Request::AddPostData(std::pair<ByteString, ByteString> data)
{
std::map<ByteString, ByteString> postData;
postData.insert(data);
@ -47,7 +47,7 @@ void Download::AddPostData(std::pair<ByteString, ByteString> data)
}
// add userID and sessionID headers to the download. Must be done after download starts for some reason
void Download::AuthHeaders(ByteString ID, ByteString session)
void Request::AuthHeaders(ByteString ID, ByteString session)
{
if (ID != "0")
userID = ID;
@ -55,7 +55,7 @@ void Download::AuthHeaders(ByteString ID, ByteString session)
}
// start the download thread
void Download::Start()
void Request::Start()
{
if (CheckStarted() || CheckDone())
return;
@ -65,19 +65,19 @@ void Download::Start()
http_auth_headers(http, userID.c_str(), NULL, userSession.c_str());
if (postDataBoundary.length())
http_add_multipart_header(http, postDataBoundary);
DownloadManager::Ref().Lock();
RequestManager::Ref().Lock();
downloadStarted = true;
DownloadManager::Ref().Unlock();
RequestManager::Ref().Unlock();
}
// finish the download (if called before the download is done, this will block)
ByteString Download::Finish(int *status)
ByteString Request::Finish(int *status)
{
if (CheckCanceled())
return ""; // shouldn't happen but just in case
while (!CheckDone()); // block
DownloadManager::Ref().Lock();
RequestManager::Ref().Lock();
downloadStarted = false;
if (status)
*status = downloadStatus;
@ -90,60 +90,60 @@ ByteString Download::Finish(int *status)
downloadData = NULL;
if (!keepAlive)
downloadCanceled = true;
DownloadManager::Ref().Unlock();
RequestManager::Ref().Unlock();
return ret;
}
// returns the download size and progress (if the download has the correct length headers)
void Download::CheckProgress(int *total, int *done)
void Request::CheckProgress(int *total, int *done)
{
DownloadManager::Ref().Lock();
RequestManager::Ref().Lock();
if (!downloadFinished && http)
http_async_get_length(http, total, done);
else
*total = *done = 0;
DownloadManager::Ref().Unlock();
RequestManager::Ref().Unlock();
}
// returns true if the download has finished
bool Download::CheckDone()
bool Request::CheckDone()
{
DownloadManager::Ref().Lock();
RequestManager::Ref().Lock();
bool ret = downloadFinished;
DownloadManager::Ref().Unlock();
RequestManager::Ref().Unlock();
return ret;
}
// returns true if the download was canceled
bool Download::CheckCanceled()
bool Request::CheckCanceled()
{
DownloadManager::Ref().Lock();
RequestManager::Ref().Lock();
bool ret = downloadCanceled;
DownloadManager::Ref().Unlock();
RequestManager::Ref().Unlock();
return ret;
}
// returns true if the download is running
bool Download::CheckStarted()
bool Request::CheckStarted()
{
DownloadManager::Ref().Lock();
RequestManager::Ref().Lock();
bool ret = downloadStarted;
DownloadManager::Ref().Unlock();
RequestManager::Ref().Unlock();
return ret;
}
// cancels the download, the download thread will delete the Download* when it finishes (do not use Download in any way after canceling)
void Download::Cancel()
// cancels the download, the download thread will delete the Request* when it finishes (do not use Request in any way after canceling)
void Request::Cancel()
{
DownloadManager::Ref().Lock();
RequestManager::Ref().Lock();
downloadCanceled = true;
DownloadManager::Ref().Unlock();
RequestManager::Ref().Unlock();
}
ByteString Download::Simple(ByteString uri, int *status, std::map<ByteString, ByteString> post_data)
ByteString Request::Simple(ByteString uri, int *status, std::map<ByteString, ByteString> post_data)
{
Download *request = new Download(uri);
Request *request = new Request(uri);
request->AddPostData(post_data);
request->Start();
while(!request->CheckDone())
@ -153,9 +153,9 @@ ByteString Download::Simple(ByteString uri, int *status, std::map<ByteString, By
return request->Finish(status);
}
ByteString Download::SimpleAuth(ByteString uri, int *status, ByteString ID, ByteString session, std::map<ByteString, ByteString> post_data)
ByteString Request::SimpleAuth(ByteString uri, int *status, ByteString ID, ByteString session, std::map<ByteString, ByteString> post_data)
{
Download *request = new Download(uri);
Request *request = new Request(uri);
request->AddPostData(post_data);
request->AuthHeaders(ID, session);
request->Start();

View File

@ -5,8 +5,8 @@
namespace http
{
class DownloadManager;
class Download
class RequestManager;
class Request
{
ByteString uri;
void *http;
@ -27,8 +27,8 @@ class Download
volatile bool downloadStarted;
public:
Download(ByteString uri, bool keepAlive = false);
virtual ~Download();
Request(ByteString uri, bool keepAlive = false);
virtual ~Request();
void AddPostData(std::map<ByteString, ByteString> data);
void AddPostData(std::pair<ByteString, ByteString> data);
@ -42,7 +42,7 @@ public:
bool CheckCanceled();
bool CheckStarted();
friend class DownloadManager;
friend class RequestManager;
static ByteString Simple(ByteString uri, int *status, std::map<ByteString, ByteString> post_data = {});
static ByteString SimpleAuth(ByteString uri, int *status, ByteString ID, ByteString session, std::map<ByteString, ByteString> post_data = {});

View File

@ -1,35 +1,35 @@
#include "DownloadManager.h"
#include "Download.h"
#include "RequestManager.h"
#include "Request.h"
#include "HTTP.h"
#include "Config.h"
#include "Platform.h"
namespace http
{
DownloadManager::DownloadManager():
RequestManager::RequestManager():
threadStarted(false),
lastUsed(time(NULL)),
managerRunning(false),
managerShutdown(false),
downloads(std::vector<Download*>()),
downloadsAddQueue(std::vector<Download*>())
downloads(std::vector<Request*>()),
downloadsAddQueue(std::vector<Request*>())
{
pthread_mutex_init(&downloadLock, NULL);
pthread_mutex_init(&downloadAddLock, NULL);
}
DownloadManager::~DownloadManager()
RequestManager::~RequestManager()
{
}
void DownloadManager::Shutdown()
void RequestManager::Shutdown()
{
pthread_mutex_lock(&downloadLock);
pthread_mutex_lock(&downloadAddLock);
for (std::vector<Download*>::iterator iter = downloads.begin(); iter != downloads.end(); ++iter)
for (std::vector<Request*>::iterator iter = downloads.begin(); iter != downloads.end(); ++iter)
{
Download *download = (*iter);
Request *download = (*iter);
if (download->http)
http_force_close(download->http);
download->downloadCanceled = true;
@ -47,14 +47,14 @@ void DownloadManager::Shutdown()
}
//helper function for download
TH_ENTRY_POINT void* DownloadManagerHelper(void* obj)
TH_ENTRY_POINT void* RequestManagerHelper(void* obj)
{
DownloadManager *temp = (DownloadManager*)obj;
RequestManager *temp = (RequestManager*)obj;
temp->Update();
return NULL;
}
void DownloadManager::Initialise(ByteString Proxy)
void RequestManager::Initialise(ByteString Proxy)
{
proxy = Proxy;
if (proxy.length())
@ -67,14 +67,14 @@ void DownloadManager::Initialise(ByteString Proxy)
}
}
void DownloadManager::Start()
void RequestManager::Start()
{
managerRunning = true;
lastUsed = time(NULL);
pthread_create(&downloadThread, NULL, &DownloadManagerHelper, this);
pthread_create(&downloadThread, NULL, &RequestManagerHelper, this);
}
void DownloadManager::Update()
void RequestManager::Update()
{
unsigned int numActiveDownloads = 0;
while (!managerShutdown)
@ -95,7 +95,7 @@ void DownloadManager::Update()
pthread_mutex_lock(&downloadLock);
for (size_t i = 0; i < downloads.size(); i++)
{
Download *download = downloads[i];
Request *download = downloads[i];
if (download->downloadCanceled)
{
if (download->http && download->downloadStarted)
@ -130,7 +130,7 @@ void DownloadManager::Update()
}
}
void DownloadManager::EnsureRunning()
void RequestManager::EnsureRunning()
{
pthread_mutex_lock(&downloadLock);
if (!managerRunning)
@ -144,7 +144,7 @@ void DownloadManager::EnsureRunning()
pthread_mutex_unlock(&downloadLock);
}
void DownloadManager::AddDownload(Download *download)
void RequestManager::AddDownload(Request *download)
{
pthread_mutex_lock(&downloadAddLock);
downloadsAddQueue.push_back(download);
@ -152,12 +152,12 @@ void DownloadManager::AddDownload(Download *download)
EnsureRunning();
}
void DownloadManager::Lock()
void RequestManager::Lock()
{
pthread_mutex_lock(&downloadAddLock);
}
void DownloadManager::Unlock()
void RequestManager::Unlock()
{
pthread_mutex_unlock(&downloadAddLock);
}

View File

@ -8,8 +8,8 @@
namespace http
{
class Download;
class DownloadManager : public Singleton<DownloadManager>
class Request;
class RequestManager : public Singleton<RequestManager>
{
private:
pthread_t downloadThread;
@ -21,13 +21,13 @@ private:
int lastUsed;
volatile bool managerRunning;
volatile bool managerShutdown;
std::vector<Download*> downloads;
std::vector<Download*> downloadsAddQueue;
std::vector<Request*> downloads;
std::vector<Request*> downloadsAddQueue;
void Start();
public:
DownloadManager();
~DownloadManager();
RequestManager();
~RequestManager();
void Initialise(ByteString proxy);
@ -35,7 +35,7 @@ public:
void Update();
void EnsureRunning();
void AddDownload(Download *download);
void AddDownload(Request *download);
void RemoveDownload(int id);
void Lock();

View File

@ -1,11 +1,11 @@
#ifndef SAVEUSERINFOREQUEST2_H
#define SAVEUSERINFOREQUEST2_H
#include "Download.h"
#include "Request.h"
#include "common/String.h"
#include "json/json.h"
#include "client/Client.h"
#include "client/APIRequest.h"
#include "APIRequest.h"
#include <memory>
#include <map>

View File

@ -6,8 +6,8 @@
#include "Component.h"
#include "graphics/Graphics.h"
#include "gui/interface/Colour.h"
#include "client/AvatarRequest.h"
#include "client/RequestMonitor.h"
#include "client/http/AvatarRequest.h"
#include "client/http/RequestMonitor.h"
#include <memory>

View File

@ -8,8 +8,8 @@
#include "client/SaveInfo.h"
#include "graphics/Graphics.h"
#include "gui/interface/Colour.h"
#include "client/ThumbnailRequest.h"
#include "client/RequestMonitor.h"
#include "client/http/ThumbnailRequest.h"
#include "client/http/RequestMonitor.h"
#include "graphics/Graphics.h"
#include <memory>

View File

@ -75,13 +75,13 @@ void PreviewModel::UpdateSave(int saveID, int saveDate)
url = ByteString::Build("http://", STATICSERVER, "/", saveID, "_", saveDate, ".cps");
else
url = ByteString::Build("http://", STATICSERVER, "/", saveID, ".cps");
saveDataDownload = new http::Download(url);
saveDataDownload = new http::Request(url);
saveDataDownload->Start();
url = ByteString::Build("http://", SERVER , "/Browse/View.json?ID=", saveID);
if (saveDate)
url += ByteString::Build("&Date=", saveDate);
saveInfoDownload = new http::Download(url);
saveInfoDownload = new http::Request(url);
saveInfoDownload->AuthHeaders(ByteString::Build(Client::Ref().GetAuthUser().UserID), Client::Ref().GetAuthUser().SessionID);
saveInfoDownload->Start();
@ -90,7 +90,7 @@ void PreviewModel::UpdateSave(int saveID, int saveDate)
commentsLoaded = false;
url = ByteString::Build("http://", SERVER, "/Browse/Comments.json?ID=", saveID, "&Start=", (commentsPageNumber-1)*20, "&Count=20");
commentsDownload = new http::Download(url);
commentsDownload = new http::Request(url);
commentsDownload->AuthHeaders(ByteString::Build(Client::Ref().GetAuthUser().UserID), Client::Ref().GetAuthUser().SessionID);
commentsDownload->Start();
}
@ -142,7 +142,7 @@ void PreviewModel::UpdateComments(int pageNumber)
if (!GetDoOpen())
{
ByteString url = ByteString::Build("http://", SERVER, "/Browse/Comments.json?ID=", saveID, "&Start=", (commentsPageNumber-1)*20, "&Count=20");
commentsDownload = new http::Download(url);
commentsDownload = new http::Request(url);
commentsDownload->AuthHeaders(ByteString::Build(Client::Ref().GetAuthUser().UserID), Client::Ref().GetAuthUser().SessionID);
commentsDownload->Start();
}
@ -239,7 +239,7 @@ bool PreviewModel::ParseSaveInfo(ByteString &saveInfoResponse)
saveDataDownload->Cancel();
delete saveData;
saveData = NULL;
saveDataDownload = new http::Download(ByteString::Build("http://", STATICSERVER, "/2157797.cps"));
saveDataDownload = new http::Request(ByteString::Build("http://", STATICSERVER, "/2157797.cps"));
saveDataDownload->Start();
}
return true;

View File

@ -6,7 +6,7 @@
#include "PreviewView.h"
#include "client/SaveInfo.h"
#include "gui/preview/Comment.h"
#include "client/Download.h"
#include "client/http/Request.h"
using namespace std;
@ -23,9 +23,9 @@ class PreviewModel {
void notifyCommentsPageChanged();
void notifyCommentBoxEnabledChanged();
http::Download * saveDataDownload;
http::Download * saveInfoDownload;
http::Download * commentsDownload;
http::Request * saveDataDownload;
http::Request * saveInfoDownload;
http::Request * commentsDownload;
int saveID;
int saveDate;

View File

@ -5,9 +5,9 @@
#include "Activity.h"
#include "client/UserInfo.h"
#include "gui/interface/Window.h"
#include "client/SaveUserInfoRequest.h"
#include "client/GetUserInfoRequest.h"
#include "client/RequestMonitor.h"
#include "client/http/SaveUserInfoRequest.h"
#include "client/http/GetUserInfoRequest.h"
#include "client/http/RequestMonitor.h"
namespace ui
{

View File

@ -5,7 +5,7 @@
#include "tasks/Task.h"
#include "client/Client.h"
#include "Update.h"
#include "client/Download.h"
#include "client/http/Request.h"
#include "Platform.h"
@ -26,7 +26,7 @@ private:
virtual bool doWork()
{
String error;
http::Download *request = new http::Download(updateName);
http::Request *request = new http::Request(updateName);
request->Start();
notifyStatus("Downloading update");
notifyProgress(-1);
@ -149,7 +149,7 @@ void UpdateActivity::NotifyError(Task * sender)
if (result == ConfirmPrompt::ResultOkay)
{
#ifndef UPDATESERVER
Platform::OpenURI("http://powdertoy.co.uk/Download.html");
Platform::OpenURI("http://powdertoy.co.uk/http/Request.html");
#endif
}
a->Exit();

View File

@ -4,7 +4,7 @@
#include <algorithm>
#include <locale>
#include "client/Download.h"
#include "client/http/Request.h"
#include "Format.h"
#include "LuaScriptInterface.h"
#include "LuaScriptHelper.h"
@ -1355,7 +1355,7 @@ int luatpt_getscript(lua_State* l)
return 0;
int ret;
ByteString scriptData = http::Download::Simple(url, &ret);
ByteString scriptData = http::Request::Simple(url, &ret);
if (!scriptData.size() || !filename)
{
return luaL_error(l, "Server did not return data");

View File

@ -20,7 +20,6 @@
#include "gui/game/GameModel.h"
#include "gui/game/Tool.h"
#include "LuaScriptHelper.h"
#include "client/HTTP.h"
#include "client/GameSave.h"
#include "client/SaveFile.h"
#include "Misc.h"