Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion scene/main/http_request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#include "http_request.h"

#include "core/io/dir_access.h"
#include "core/io/file_access.h"
#include "core/io/stream_peer_gzip.h"
#include "core/object/callable_mp.h"
Expand Down Expand Up @@ -204,13 +205,20 @@ void HTTPRequest::cancel_request() {
}
}

file.unref();
if (file.is_valid()) {
file.unref();
if (!download_complete) {
DirAccess::remove_absolute(download_to_file);
}
}

decompressor.unref();
client->close();
body.clear();
got_response = false;
response_code = -1;
request_sent = false;
download_complete = false;
requesting = false;
}

Expand Down Expand Up @@ -501,6 +509,7 @@ bool HTTPRequest::_update_connection() {

if (body_len >= 0) {
if (downloaded.get() == body_len) {
download_complete = true;
_defer_done(RESULT_SUCCESS, response_code, response_headers, body);
return true;
}
Expand Down
1 change: 1 addition & 0 deletions scene/main/http_request.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class HTTPRequest : public Node {

private:
bool requesting = false;
bool download_complete = false;

String request_string;
String url;
Expand Down
Loading