summaryrefslogtreecommitdiff
path: root/scene/main/http_request.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/main/http_request.cpp')
-rw-r--r--scene/main/http_request.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/scene/main/http_request.cpp b/scene/main/http_request.cpp
index 1603ad66be..82ee4dde50 100644
--- a/scene/main/http_request.cpp
+++ b/scene/main/http_request.cpp
@@ -94,8 +94,9 @@ Error HTTPRequest::request(const String &p_url, const Vector<String> &p_custom_h
method = p_method;
Error err = _parse_url(p_url);
- if (err)
+ if (err) {
return err;
+ }
validate_ssl = p_ssl_validate_domain;
@@ -134,8 +135,9 @@ void HTTPRequest::_thread_func(void *p_userdata) {
} else {
while (!hr->thread_request_quit) {
bool exit = hr->_update_connection();
- if (exit)
+ if (exit) {
break;
+ }
OS::get_singleton()->delay_usec(1);
}
}
@@ -146,8 +148,9 @@ void HTTPRequest::_thread_func(void *p_userdata) {
void HTTPRequest::cancel_request() {
timer->stop();
- if (!requesting)
+ if (!requesting) {
return;
+ }
if (!use_threads) {
set_process_internal(false);
@@ -266,8 +269,9 @@ bool HTTPRequest::_update_connection() {
bool ret_value;
- if (_handle_response(&ret_value))
+ if (_handle_response(&ret_value)) {
return ret_value;
+ }
call_deferred("_request_done", RESULT_SUCCESS, response_code, response_headers, PackedByteArray());
return true;
@@ -304,8 +308,9 @@ bool HTTPRequest::_update_connection() {
if (!got_response) {
bool ret_value;
- if (_handle_response(&ret_value))
+ if (_handle_response(&ret_value)) {
return ret_value;
+ }
if (!client->is_response_chunked() && client->get_response_body_length() == 0) {
call_deferred("_request_done", RESULT_SUCCESS, response_code, response_headers, PackedByteArray());
@@ -384,8 +389,9 @@ void HTTPRequest::_request_done(int p_status, int p_code, const PackedStringArra
void HTTPRequest::_notification(int p_what) {
if (p_what == NOTIFICATION_INTERNAL_PROCESS) {
- if (use_threads)
+ if (use_threads) {
return;
+ }
bool done = _update_connection();
if (done) {
set_process_internal(false);
@@ -556,6 +562,7 @@ HTTPRequest::HTTPRequest() {
}
HTTPRequest::~HTTPRequest() {
- if (file)
+ if (file) {
memdelete(file);
+ }
}