19 #ifndef HEADER_HTTP_REQUEST_HPP
20 #define HEADER_HTTP_REQUEST_HPP
22 #include "online/request.hpp"
23 #include "utils/cpp2011.hpp"
24 #include "utils/string_utils.hpp"
33 bool globalHTTPRequestInit();
34 void globalHTTPRequestCleanup();
39 static const std::string USER_PATH;
40 static const std::string SERVER_PATH;
54 std::atomic<double> m_total_size;
68 #ifdef APPLE_NETWORK_LIBRARIES
69 std::string m_error_string;
72 std::string urlEncode(
const std::string& value);
80 bool m_disable_sending_log;
84 bool m_download_assets_request;
91 HTTPRequest(const std::
string &filename,
int priority = 1);
92 HTTPRequest(const
char * const filename,
int priority = 1);
94 void setApiURL(const std::
string& url, const std::
string &action);
101 void setDownloadAssetsRequest(
bool val)
102 { m_download_assets_request = val; }
129 const irr::core::stringw &value)
131 std::string s = StringUtils::wideToUtf8(value);
139 template <
typename T>
143 std::string s = StringUtils::toString(value);
144 std::string s1 = urlEncode(name);
145 std::string s2 = urlEncode(s);
158 const std::string & getURL()
const { assert(
isBusy());
return m_url;}
168 const std::string& getFileName()
const {
return m_filename; }
170 double getTotalSize()
const {
return m_total_size.load(); }
172 void setTotalSize(
double d) { m_total_size.store(d); }
Definition: http_request.hpp:37
A http request.
Definition: http_request.hpp:46
std::string m_string_buffer
String to store the received data in.
Definition: http_request.hpp:66
void addParameter(const std::string &name, const T &value)
Sets a parameter to 'value' (arbitrary types).
Definition: http_request.hpp:140
float getProgress() const
Returns the current progress.
Definition: http_request.hpp:151
std::atomic< float > m_progress
The progress indicator.
Definition: http_request.hpp:52
int64_t m_result_code
Result code from request implementation, 0 if succeeded.
Definition: http_request.hpp:63
void setProgress(float f)
Sets the current progress.
Definition: http_request.hpp:155
virtual bool isAllowedToAdd() const OVERRIDE
Checks the request if it has enough (correct) information to be executed (and thus allowed to add to ...
Definition: http_request.cpp:143
void init()
Initialises all member variables.
Definition: http_request.cpp:83
void setAddonsURL(const std::string &path)
A handy shortcut that appends the given path to the URL of the addons server.
Definition: http_request.cpp:134
virtual void operation() OVERRIDE
The actual operation to be executed.
Definition: http_request_curl.cpp:107
std::string m_filename
Contains a filename if the data should be saved into a file instead of being kept in memory.
Definition: http_request.hpp:78
std::string m_parameters
The POST parameters that will be sent with the request.
Definition: http_request.hpp:60
const char * getDownloadErrorMessage() const
Returns the error message if an error has occurred.
Definition: http_request_curl.cpp:239
void addParameter(const std::string &name, const irr::core::stringw &value)
Sets a parameter to 'value' (stringw).
Definition: http_request.hpp:128
void setApiURL(const std::string &url, const std::string &action)
A handy shortcut that appends the given path to the URL of the mutiplayer server.
Definition: http_request.cpp:103
void addParameter(const std::string &name, const std::string &value)
Sets a parameter to 'value' (std::string).
Definition: http_request.hpp:120
virtual bool hadDownloadError() const
Returns true if there was an error downloading the file.
Definition: http_request.hpp:99
void setURL(const std::string &url)
Sets the URL for this request.
Definition: http_request.hpp:162
const std::string & getData() const
Returns the downloaded string.
Definition: http_request.hpp:112
std::string m_url
The url to download.
Definition: http_request.hpp:57
Stores a request for the HTTP Manager.
Definition: request.hpp:58
bool isPreparing() const
Returns if this request is being prepared.
Definition: request.hpp:187
bool hasBeenExecuted() const
Checks if the request has completed or done (i.e.
Definition: request.hpp:197
bool isBusy() const
Returns if this request is busy.
Definition: request.hpp:191