summaryrefslogtreecommitdiff
path: root/editor/plugins
diff options
context:
space:
mode:
authorHaoyu Qiu <timothyqiu32@gmail.com>2021-12-09 11:34:32 +0800
committerHaoyu Qiu <timothyqiu32@gmail.com>2021-12-09 11:48:16 +0800
commit5912dd296487242b528836efc9dd045356ec3593 (patch)
treeff3bc80e5b7ec737618daca330b3e32a756d6875 /editor/plugins
parentf1e3c87244f18ab1a507b6e3637c34b2d49c1dc6 (diff)
Add proxy support for the editor
* Adds proxy support for `HTTPRequest`. * Adds `network/http_proxy/{host,port}` editor settings. * Labeled as "HTTP Proxy" and it will be used for both HTTP and HTTPS requests. This is the same convention as seen in Android Studio's proxy settings. * Makes Asset Library and Export Template Manager use proxy according to the editor settings.
Diffstat (limited to 'editor/plugins')
-rw-r--r--editor/plugins/asset_library_editor_plugin.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp
index 5cfd7525e5..65ec263abc 100644
--- a/editor/plugins/asset_library_editor_plugin.cpp
+++ b/editor/plugins/asset_library_editor_plugin.cpp
@@ -39,6 +39,15 @@
#include "editor/editor_settings.h"
#include "editor/project_settings_editor.h"
+static inline void setup_http_request(HTTPRequest *request) {
+ request->set_use_threads(EDITOR_DEF("asset_library/use_threads", true));
+
+ const String proxy_host = EDITOR_DEF("network/http_proxy/host", "");
+ const int proxy_port = EDITOR_DEF("network/http_proxy/port", -1);
+ request->set_http_proxy(proxy_host, proxy_port);
+ request->set_https_proxy(proxy_host, proxy_port);
+}
+
void EditorAssetLibraryItem::configure(const String &p_title, int p_asset_id, const String &p_category, int p_category_id, const String &p_author, int p_author_id, const String &p_cost) {
title->set_text(p_title);
asset_id = p_asset_id;
@@ -533,7 +542,7 @@ EditorAssetLibraryItemDownload::EditorAssetLibraryItemDownload() {
download = memnew(HTTPRequest);
add_child(download);
download->connect("request_completed", callable_mp(this, &EditorAssetLibraryItemDownload::_http_download_completed));
- download->set_use_threads(EDITOR_DEF("asset_library/use_threads", true));
+ setup_http_request(download);
download_error = memnew(AcceptDialog);
add_child(download_error);
@@ -868,7 +877,7 @@ void EditorAssetLibrary::_request_image(ObjectID p_for, String p_image_url, Imag
iq.image_index = p_image_index;
iq.image_type = p_type;
iq.request = memnew(HTTPRequest);
- iq.request->set_use_threads(EDITOR_DEF("asset_library/use_threads", true));
+ setup_http_request(iq.request);
iq.target = p_for;
iq.queue_id = ++last_queue_id;
@@ -1475,7 +1484,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
request = memnew(HTTPRequest);
add_child(request);
- request->set_use_threads(EDITOR_DEF("asset_library/use_threads", true));
+ setup_http_request(request);
request->connect("request_completed", callable_mp(this, &EditorAssetLibrary::_http_request_completed));
last_queue_id = 0;