diff options
Diffstat (limited to 'scene/main/http_request.cpp')
-rw-r--r-- | scene/main/http_request.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/scene/main/http_request.cpp b/scene/main/http_request.cpp index a4fcc04e20..2dbfb43ad3 100644 --- a/scene/main/http_request.cpp +++ b/scene/main/http_request.cpp @@ -243,7 +243,7 @@ bool HTTPRequest::_handle_response(bool *ret_value) { } } - if (new_request != "") { + if (!new_request.is_empty()) { // Process redirect client->close(); int new_redirs = redirections + 1; // Because _request() will clear it @@ -363,7 +363,7 @@ bool HTTPRequest::_update_connection() { return true; } - if (download_to_file != String()) { + if (!download_to_file.is_empty()) { file = FileAccess::open(download_to_file, FileAccess::WRITE); if (!file) { call_deferred(SNAME("_request_done"), RESULT_DOWNLOAD_FILE_CANT_OPEN, response_code, response_headers, PackedByteArray()); @@ -554,6 +554,14 @@ int HTTPRequest::get_body_size() const { return body_len; } +void HTTPRequest::set_http_proxy(const String &p_host, int p_port) { + client->set_http_proxy(p_host, p_port); +} + +void HTTPRequest::set_https_proxy(const String &p_host, int p_port) { + client->set_https_proxy(p_host, p_port); +} + void HTTPRequest::set_timeout(int p_timeout) { ERR_FAIL_COND(p_timeout < 0); timeout = p_timeout; @@ -602,6 +610,9 @@ void HTTPRequest::_bind_methods() { ClassDB::bind_method(D_METHOD("set_download_chunk_size", "chunk_size"), &HTTPRequest::set_download_chunk_size); ClassDB::bind_method(D_METHOD("get_download_chunk_size"), &HTTPRequest::get_download_chunk_size); + ClassDB::bind_method(D_METHOD("set_http_proxy", "host", "port"), &HTTPRequest::set_http_proxy); + ClassDB::bind_method(D_METHOD("set_https_proxy", "host", "port"), &HTTPRequest::set_https_proxy); + ADD_PROPERTY(PropertyInfo(Variant::STRING, "download_file", PROPERTY_HINT_FILE), "set_download_file", "get_download_file"); ADD_PROPERTY(PropertyInfo(Variant::INT, "download_chunk_size", PROPERTY_HINT_RANGE, "256,16777216"), "set_download_chunk_size", "get_download_chunk_size"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_threads"), "set_use_threads", "is_using_threads"); |