]> git.mxchange.org Git - simgear.git/blobdiff - simgear/io/httpget.cxx
Fix VS2010 lack of fminf
[simgear.git] / simgear / io / httpget.cxx
index a8e226066a7bbf2f67d6e8496a82ce9f3844c96b..876ba14ff9aa9f4bf52cc882db99d30a8be54153 100644 (file)
@@ -1,18 +1,18 @@
 
 #include <cstdio>
 #include <cstring>
+#include <signal.h>
 
-#include <unistd.h> // for STDOUT_FILENO
 #include <iostream>
 #include <boost/foreach.hpp>
-#include <signal.h>
+
 
 #include <simgear/io/sg_file.hxx>
 #include <simgear/io/HTTPClient.hxx>
 #include <simgear/io/HTTPRequest.hxx>
 #include <simgear/io/sg_netChannel.hxx>
 #include <simgear/misc/strutils.hxx>
-#include <simgear/misc/sg_sleep.hxx>
+#include <simgear/timing/timestamp.hxx>
 
 using namespace simgear;
 using std::cout;
@@ -48,35 +48,11 @@ public:
         }
         
         string key = h.substr(0, colonPos);
-        _headers[key] = h.substr(colonPos + 1);
-    }
-    
-    virtual string_list requestHeaders() const
-    {
-        string_list r;
-        std::map<string, string>::const_iterator it;
-        for (it = _headers.begin(); it != _headers.end(); ++it) {
-            r.push_back(it->first);
-        }
-        
-        return r;
+        requestHeader(key) = h.substr(colonPos + 1);
     }
     
-    virtual string header(const string& name) const
-    {
-        std::map<string, string>::const_iterator it = _headers.find(name);
-        if (it == _headers.end()) {
-            return string();
-        }
-        
-        return it->second;
-    }
 protected:
-    virtual void responseHeadersComplete()
-    {
-    }
-
-    virtual void responseComplete()
+    virtual void onDone()
     {
         _complete = true;
     }  
@@ -88,13 +64,12 @@ protected:
 private:    
     bool _complete;
     SGFile* _file;
-    std::map<string, string> _headers;
 };
 
 int main(int argc, char* argv[])
 {
     HTTP::Client cl;
-    SGFile* outFile;
+    SGFile* outFile = 0;
     string proxy, proxyAuth;
     string_list headers;
     string url;
@@ -133,10 +108,12 @@ int main(int argc, char* argv[])
         cl.setProxy(proxyHost, proxyPort, proxyAuth);
     }
 
+#ifndef WIN32
     signal(SIGPIPE, SIG_IGN);
+#endif
 
     if (!outFile) {
-        outFile = new SGFile(STDOUT_FILENO);
+        outFile = new SGFile(fileno(stdout));
     }
 
     if (url.empty()) {
@@ -154,7 +131,7 @@ int main(int argc, char* argv[])
     
     while (!req->complete()) {
         cl.update();
-        sleepForMSec(100);
+        SGTimeStamp::sleepForMSec(100);
     }
         
     if (req->responseCode() != 200) {