From aea71cf0afd20f184f8c4c719e25e31d95003bc9 Mon Sep 17 00:00:00 2001 From: Thomas Geymayer Date: Mon, 30 Dec 2013 01:31:47 +0100 Subject: [PATCH] HTTPFileRequest: only save file if status == 200 --- simgear/io/HTTPFileRequest.cxx | 7 +++++-- simgear/io/HTTPRequest.hxx | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/simgear/io/HTTPFileRequest.cxx b/simgear/io/HTTPFileRequest.cxx index 69c89cdd..81ddb012 100644 --- a/simgear/io/HTTPFileRequest.cxx +++ b/simgear/io/HTTPFileRequest.cxx @@ -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; } diff --git a/simgear/io/HTTPRequest.hxx b/simgear/io/HTTPRequest.hxx index 89a953bc..c9b9de66 100644 --- a/simgear/io/HTTPRequest.hxx +++ b/simgear/io/HTTPRequest.hxx @@ -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; -- 2.39.5