HTTP/curl - transfer byte metric work
Should fix the missing download rate feedback on the splash screen and terra sync dialog.
This commit is contained in:
parent
714a6ac47d
commit
3f9b6d632e
@ -876,6 +876,8 @@ void Client::makeRequest(const Request_ptr& r)
|
||||
return;
|
||||
}
|
||||
|
||||
r->_client = this;
|
||||
|
||||
#if defined(ENABLE_CURL)
|
||||
CURL* curlRequest = curl_easy_init();
|
||||
curl_easy_setopt(curlRequest, CURLOPT_URL, r->url().c_str());
|
||||
@ -1136,9 +1138,14 @@ uint64_t Client::totalBytesDownloaded() const
|
||||
size_t Client::requestWriteCallback(char *ptr, size_t size, size_t nmemb, void *userdata)
|
||||
{
|
||||
size_t byteSize = size * nmemb;
|
||||
|
||||
Request* req = static_cast<Request*>(userdata);
|
||||
req->processBodyBytes(ptr, byteSize);
|
||||
|
||||
Client* cl = req->http();
|
||||
if (cl) {
|
||||
cl->receivedBytes(byteSize);
|
||||
}
|
||||
|
||||
return byteSize;
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,7 @@ extern const int DEFAULT_HTTP_PORT;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
Request::Request(const std::string& url, const std::string method):
|
||||
_client(0),
|
||||
_method(method),
|
||||
_url(url),
|
||||
_responseVersion(HTTP_VERSION_UNKNOWN),
|
||||
|
@ -37,6 +37,8 @@ namespace simgear
|
||||
namespace HTTP
|
||||
{
|
||||
|
||||
class Client;
|
||||
|
||||
/**
|
||||
* Base class for HTTP request (and answer).
|
||||
*/
|
||||
@ -131,6 +133,9 @@ public:
|
||||
virtual std::string url() const
|
||||
{ return _url; }
|
||||
|
||||
Client* http() const
|
||||
{ return _client; }
|
||||
|
||||
virtual std::string scheme() const;
|
||||
virtual std::string path() const;
|
||||
virtual std::string host() const;
|
||||
@ -241,6 +246,8 @@ private:
|
||||
void processBodyBytes(const char* s, int n);
|
||||
void setReadyState(ReadyState state);
|
||||
|
||||
Client* _client; // HTTP client we're active on
|
||||
|
||||
std::string _method;
|
||||
std::string _url;
|
||||
StringMap _request_headers;
|
||||
|
Loading…
Reference in New Issue
Block a user