X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fio%2FHTTPClient.hxx;h=c726dc60e608cb61fa0edb34d13faab0ed62b1cb;hb=3bcd0bafd5fba1eebadfd1cb8a7294d665cf1932;hp=530552cdf4f0ee9549dae761e937b880abf4da9a;hpb=9c7bd4f5d51db9a770a23cc9c96c9542c65df3b1;p=simgear.git diff --git a/simgear/io/HTTPClient.hxx b/simgear/io/HTTPClient.hxx index 530552cd..c726dc60 100644 --- a/simgear/io/HTTPClient.hxx +++ b/simgear/io/HTTPClient.hxx @@ -24,7 +24,11 @@ #ifndef SG_HTTP_CLIENT_HXX #define SG_HTTP_CLIENT_HXX -#include +#include // for std::auto_ptr +#include // for uint_64t + +#include +#include namespace simgear { @@ -44,7 +48,24 @@ public: void update(int waitTimeout = 0); void makeRequest(const Request_ptr& r); - + + /** + * Download a resource and save it to a file. + * + * @param url The resource to download + * @param filename Path to the target file + * @param data Data for POST request + */ + FileRequestRef save( const std::string& url, + const std::string& filename ); + + /** + * Request a resource and keep it in memory. + * + * @param url The resource to download + */ + MemoryRequestRef load(const std::string& url); + void setUserAgent(const std::string& ua); void setProxy(const std::string& proxy, int port, const std::string& auth = ""); @@ -64,10 +85,24 @@ public: * predicate, check if at least one connection is active, with at * least one request active or queued. */ - bool hasActiveRequests() const; + bool hasActiveRequests() const; + + /** + * crude tracking of bytes-per-second transferred over the socket. + * suitable for user feedback and rough profiling, nothing more. + */ + unsigned int transferRateBytesPerSec() const; + + /** + * total bytes downloaded by this HTTP client, for bandwidth usage + * monitoring + */ + uint64_t totalBytesDownloaded() const; private: void requestFinished(Connection* con); + void receivedBytes(unsigned int count); + friend class Connection; friend class Request;