]> git.mxchange.org Git - simgear.git/commitdiff
HTTPFileRequest: only save file if status == 200
authorThomas Geymayer <tomgey@gmail.com>
Mon, 30 Dec 2013 00:31:47 +0000 (01:31 +0100)
committerThomas Geymayer <tomgey@gmail.com>
Mon, 30 Dec 2013 00:31:47 +0000 (01:31 +0100)
simgear/io/HTTPFileRequest.cxx
simgear/io/HTTPRequest.hxx

index 69c89cdd5d87cb3a6a2a3290ef7b803902e279b1..81ddb01231a97cae415dfbb1ff9551340123dc07 100644 (file)
@@ -38,6 +38,9 @@ namespace HTTP
   {
     Request::responseHeadersComplete();
 
+    if( responseCode() != 200 )
+      return setFailure(responseCode(), responseReason());
+
     if( !_filename.empty() )
     {
       // TODO validate path? (would require to expose fgValidatePath somehow to
@@ -69,8 +72,8 @@ namespace HTTP
       SG_LOG
       (
         SG_IO,
-        SG_WARN,
-        "HTTP::FileRequest: error writing to '" << _filename << "'"
+        SG_DEBUG,
+        "HTTP::FileRequest: received data for closed file '" << _filename << "'"
       );
       return;
     }
index 89a953bc6a64dd0514275c3414b3585b6fa337e7..c9b9de66a78d3d339af47d832098dda16c9dbea5 100644 (file)
@@ -177,6 +177,8 @@ protected:
     virtual void onFail();
     virtual void onAlways();
 
+    void setFailure(int code, const std::string& reason);
+
 private:
     friend class Client;
     friend class Connection;
@@ -186,7 +188,6 @@ private:
     Request& operator=(const Request&); // = delete;
 
     void processBodyBytes(const char* s, int n);
-    void setFailure(int code, const std::string& reason);
     void setReadyState(ReadyState state);
 
     std::string   _method;