mirror of
https://github.com/Redot-Engine/redot-engine.git
synced 2025-12-06 23:31:53 -05:00
Add download_chunk_size property to HTTPRequest.
This allows setting the `read_chunk_size` of the internal HTTPClient. This is important to reduce the allocation overhead and number of file writes when downloading large files, allowing for better download speed.
This commit is contained in:
@@ -457,6 +457,18 @@ String HTTPRequest::get_download_file() const {
|
||||
|
||||
return download_to_file;
|
||||
}
|
||||
|
||||
void HTTPRequest::set_download_chunk_size(int p_chunk_size) {
|
||||
|
||||
ERR_FAIL_COND(get_http_client_status() != HTTPClient::STATUS_DISCONNECTED);
|
||||
|
||||
client->set_read_chunk_size(p_chunk_size);
|
||||
}
|
||||
|
||||
int HTTPRequest::get_download_chunk_size() const {
|
||||
return client->get_read_chunk_size();
|
||||
}
|
||||
|
||||
HTTPClient::Status HTTPRequest::get_http_client_status() const {
|
||||
return client->get_status();
|
||||
}
|
||||
@@ -524,9 +536,13 @@ void HTTPRequest::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_timeout", "timeout"), &HTTPRequest::set_timeout);
|
||||
ClassDB::bind_method(D_METHOD("get_timeout"), &HTTPRequest::get_timeout);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_download_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("_timeout"), &HTTPRequest::_timeout);
|
||||
|
||||
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");
|
||||
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");
|
||||
|
||||
Reference in New Issue
Block a user