Open TiberiumFusion opened 3 years ago
Quite honestly I see absolutely no reason for these extremely basic features to missing in the first place, since they are already provided by ISteamHTTP.
https://partner.steamgames.com/doc/api/ISteamHTTP#GetHTTPResponseBodySize https://partner.steamgames.com/doc/api/ISteamHTTP#GetHTTPDownloadProgressPct https://partner.steamgames.com/doc/api/ISteamHTTP#SetHTTPRequestNetworkActivityTimeout https://partner.steamgames.com/doc/api/ISteamHTTP#GetHTTPRequestWasTimedOut
Essentially duplicate of https://github.com/Facepunch/garrysmod-requests/issues/1340
Implemented timeout
field for HTTP()
(NetworkActivityTimeout, not absolute timeout).
When a request timeouts, the fail reason will now correctly be "timeout"
.
@robotboy655
What is the units of timeout
? Milliseconds? Seconds?
https://wiki.facepunch.com/gmod/Structures/HTTPRequest doesn't say anything about the new timeout
field yet.
Seconds, just like the SteamAPI method you linked.
Summary
Making http requests from Lua is very limited. There is no way to track the download progress of the server response, and there is also no way to abort the download if needed. This degrades the player experience when an addon needs to retrieve remote data that downloads slowly. This is not limited to large files. Players with slow/bad/censored/fluctuating internet can experience slow or impossible downloads (i.e. timeouts) on small data.
Progress
A. Could be a callback set in
HTTPRequest
, likefunction progress(code, loadedBytes, totalBytes)
. This could be called no more than once per tick, and only on ticks whereloadedBytes
increased. B.HTTPRequest
could include an interface for getting thecode
,loadedBytes
, andtotalBytes
values on demand.Abort
HTTPRequest
could include an interface for aborting the http request, like with progress as explained above.Timeout
HTTPRequest
could include a timeout value in seconds/milliseconds and a callback function for if a timeout occurs.