Fixes for HTTP cancellation.

(Forgot to stage these from previous commit)
This commit is contained in:
James Turner
2016-04-14 09:42:04 +01:00
parent a3f1bb546f
commit c17324b5ea
+8 -6
View File
@@ -105,11 +105,7 @@ namespace simgear
{ {
} }
virtual void cancel() virtual void cancel();
{
_directory = 0;
abort("Repository cancelled request");
}
size_t contentSize() const size_t contentSize() const
{ {
@@ -633,6 +629,12 @@ HTTPRepository::failure() const
return _d->status; return _d->status;
} }
void HTTPRepoGetRequest::cancel()
{
_directory->repository()->http->cancelRequest(this, "Reposiotry cancelled");
_directory = 0;
}
class FileGetRequest : public HTTPRepoGetRequest class FileGetRequest : public HTTPRepoGetRequest
{ {
public: public:
@@ -652,7 +654,7 @@ HTTPRepository::failure() const
file.reset(new SGFile(pathInRepo.str())); file.reset(new SGFile(pathInRepo.str()));
if (!file->open(SG_IO_OUT)) { if (!file->open(SG_IO_OUT)) {
SG_LOG(SG_TERRASYNC, SG_WARN, "unable to create file " << pathInRepo); SG_LOG(SG_TERRASYNC, SG_WARN, "unable to create file " << pathInRepo);
abort("Unable to create output file"); _directory->repository()->http->cancelRequest(this, "Unable to create output file");
} }
sha1_init(&hashContext); sha1_init(&hashContext);