return;
}
+ r->_client = this;
+
#if defined(ENABLE_CURL)
CURL* curlRequest = curl_easy_init();
curl_easy_setopt(curlRequest, CURLOPT_URL, r->url().c_str());
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;
}
//------------------------------------------------------------------------------
Request::Request(const std::string& url, const std::string method):
+ _client(0),
_method(method),
_url(url),
_responseVersion(HTTP_VERSION_UNKNOWN),
namespace HTTP
{
+class Client;
+
/**
* Base class for HTTP request (and answer).
*/
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;
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;