Limit download or upload rate
What would you like to discuss?
Is there any technique available to limit the download/upload rate to some value, e.g. 100kB/s? I was thinking about putting sleep() into some hook or somewhere but didn't find any suitable place to do that.
Because I simply supply a ReadableStream to body property, my next idea was to slow down the ReadableStream. It should work when uploading stuff but would the same work when downloading data (limit the stream that writes data to disk)? Or the data will start buffering in the memory on GOT side?
In the docs there is this example that says You can create a client that limits download speed, then compose it with an instance that signs a request. but then the limitDownloadUpload instance seems to just destroy itself when the size (not the rate) is exceeded. Is the description of the issue invalid or I don't understand something in this example?
Checklist
- [x] I have read the documentation.