From: Thomas Geymayer Date: Mon, 30 Dec 2013 00:31:47 +0000 (+0100) Subject: HTTPFileRequest: only save file if status == 200 X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=aea71cf0afd20f184f8c4c719e25e31d95003bc9;p=simgear.git HTTPFileRequest: only save file if status == 200 --- 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;