HTTPFileRequest: only save file if status == 200

This commit is contained in:
Thomas Geymayer
2013-12-30 01:31:47 +01:00
parent fb54386f8d
commit aea71cf0af
2 changed files with 7 additions and 3 deletions

View 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;
}

View 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;