]> git.mxchange.org Git - simgear.git/blobdiff - simgear/io/HTTPClient.hxx
Lots of (mostly) doxygen fixes/cleanup.
[simgear.git] / simgear / io / HTTPClient.hxx
index 530552cdf4f0ee9549dae761e937b880abf4da9a..c726dc60e608cb61fa0edb34d13faab0ed62b1cb 100644 (file)
 #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
 {
@@ -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;