You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-10 13:00:37 +00:00
Use a floating-point number for the timeout property in HTTPRequest
This allows for greater precision when specifying a timeout in HTTPRequest in `3.x`, similar to what is already possible in `master`.
This commit is contained in:
@@ -81,7 +81,7 @@ Error HTTPRequest::request_raw(const String &p_url, const Vector<String> &p_cust
|
||||
ERR_FAIL_COND_V(!is_inside_tree(), ERR_UNCONFIGURED);
|
||||
ERR_FAIL_COND_V_MSG(requesting, ERR_BUSY, "HTTPRequest is processing a request. Wait for completion or cancel it before attempting a new one.");
|
||||
|
||||
if (timeout > 0) {
|
||||
if (timeout > 0.0) {
|
||||
timer->stop();
|
||||
timer->start(timeout);
|
||||
}
|
||||
@@ -471,12 +471,16 @@ 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;
|
||||
void HTTPRequest::set_timeout(double p_timeout) {
|
||||
if (Math::is_zero_approx(p_timeout)) {
|
||||
timeout = 0.0;
|
||||
} else {
|
||||
ERR_FAIL_COND(p_timeout < 0.0);
|
||||
timeout = p_timeout;
|
||||
}
|
||||
}
|
||||
|
||||
int HTTPRequest::get_timeout() {
|
||||
double HTTPRequest::get_timeout() {
|
||||
return timeout;
|
||||
}
|
||||
|
||||
@@ -526,7 +530,7 @@ void HTTPRequest::_bind_methods() {
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_threads"), "set_use_threads", "is_using_threads");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "body_size_limit", PROPERTY_HINT_RANGE, "-1,2000000000"), "set_body_size_limit", "get_body_size_limit");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "max_redirects", PROPERTY_HINT_RANGE, "-1,64"), "set_max_redirects", "get_max_redirects");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "timeout", PROPERTY_HINT_RANGE, "0,86400"), "set_timeout", "get_timeout");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "timeout", PROPERTY_HINT_RANGE, "0,3600,0.1,or_greater"), "set_timeout", "get_timeout");
|
||||
|
||||
ADD_SIGNAL(MethodInfo("request_completed", PropertyInfo(Variant::INT, "result"), PropertyInfo(Variant::INT, "response_code"), PropertyInfo(Variant::POOL_STRING_ARRAY, "headers"), PropertyInfo(Variant::POOL_BYTE_ARRAY, "body")));
|
||||
|
||||
@@ -565,7 +569,7 @@ HTTPRequest::HTTPRequest() {
|
||||
timer->set_one_shot(true);
|
||||
timer->connect("timeout", this, "_timeout");
|
||||
add_child(timer);
|
||||
timeout = 0;
|
||||
timeout = 0.0;
|
||||
}
|
||||
|
||||
HTTPRequest::~HTTPRequest() {
|
||||
|
||||
Reference in New Issue
Block a user