Adds proxy support for HTTPClient

Also fixed a potential infinite loop when connecting to server.
This commit is contained in:
Haoyu Qiu
2021-07-03 13:11:59 +08:00
parent c5ab537617
commit c09ea8d45a
5 changed files with 129 additions and 8 deletions

View File

@ -49,6 +49,14 @@ HTTPClient *HTTPClient::create() {
return nullptr;
}
void HTTPClient::set_http_proxy(const String &p_host, int p_port) {
WARN_PRINT("HTTP proxy feature is not available");
}
void HTTPClient::set_https_proxy(const String &p_host, int p_port) {
WARN_PRINT("HTTPS proxy feature is not available");
}
Error HTTPClient::_request_raw(Method p_method, const String &p_url, const Vector<String> &p_headers, const Vector<uint8_t> &p_body) {
int size = p_body.size();
return request(p_method, p_url, p_headers, size > 0 ? p_body.ptr() : nullptr, size);
@ -142,6 +150,9 @@ void HTTPClient::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_status"), &HTTPClient::get_status);
ClassDB::bind_method(D_METHOD("poll"), &HTTPClient::poll);
ClassDB::bind_method(D_METHOD("set_http_proxy", "host", "port"), &HTTPClient::set_http_proxy);
ClassDB::bind_method(D_METHOD("set_https_proxy", "host", "port"), &HTTPClient::set_https_proxy);
ClassDB::bind_method(D_METHOD("query_string_from_dict", "fields"), &HTTPClient::query_string_from_dict);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "blocking_mode_enabled"), "set_blocking_mode", "is_blocking_mode_enabled");