godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine

Home Page:https://godotengine.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

HTTPRequest fails to download files > 2.1GB

Lyaaaaaaaaaaaaaaa opened this issue · comments

Godot version

3.4.1 stable

System information

Windows 10, Pop_OS_21

Issue description

When you try to download a file > 2.1GB it returns

E 0:00:01.826   to_int: Cannot represent 3096617152 as integer, provided value is too big.
  <Erreur C++>  Condition "overflow" is true. Returned: sign == 1 ? (2147483647) : (-2147483647-1)
  <Source C++>  core/ustring.cpp:1828 @ to_int()

E 0:00:03.111   to_int: Cannot represent 3096617152 as integer, provided value is too big.
  <Erreur C++>  Condition "overflow" is true. Returned: sign == 1 ? (2147483647) : (-2147483647-1)
  <Source C++>  core/ustring.cpp:1828 @ to_int()

And the download will end at 2.1GB. An int seems to be used to store the file's size but the size is too big.
I had the same problem to display the size because it was too big, but solved it by using float. Not sure if this "fix" can be used in this case.

Steps to reproduce

This sample is enough to trigger the error. Or you can use the reproduction project.

    var url = "https://huggingface.co/microsoft/DialoGPT-large/resolve/main/tf_model.h5"
    var ssl = false
    var headers = []

    var error = $HTTPRequest.request(url, headers, ssl, HTTPClient.METHOD_GET)

    if error == OK:
        print("download started")
    elif error == ERR_INVALID_PARAMETER:
        print("Given string isn't a valid url ")
    elif error == ERR_CANT_CONNECT:
        print("Can't connect to host")

Minimal reproduction project

httprequest.zip