#ifndef SG_HTTP_CLIENT_HXX
#define SG_HTTP_CLIENT_HXX
-#include <simgear/io/HTTPRequest.hxx>
+#include <memory> // for std::auto_ptr
+#include <stdint.h> // for uint_64t
+
+#include <simgear/io/HTTPFileRequest.hxx>
+#include <simgear/io/HTTPMemoryRequest.hxx>
namespace simgear
{
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 = "");
* 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;