cavaliergopher / grab

A download manager package for Go
BSD 3-Clause "New" or "Revised" License
1.38k stars 151 forks source link

rateLimit inaccurate when downloading files over https #58

Closed gonejack closed 5 years ago

gonejack commented 5 years ago

len(c.b) is 32k by setting grab.Client.BufferSize, rate limitation works as expectation when downloading files using http but https.

When download files over https the nr is always 16k on return, some thing from go's implementation or from some deeper tls packages when making http request over tls, said by google search.

But I made the waitN to wait the time for 32k not for 16k, for example: I would like the grab to download 3 times of 32k per second so waitN should sleep 330 milliseconds, the actually is 3 times of 16kb been downloaded.

image

cavaliercoder commented 5 years ago

This is definitely an issue! Thank you for reporting. I'll do some thinking about how to solve this.

cavaliercoder commented 5 years ago

Can you please checkout and try the code in PR #59? Does this now limit correctly for you?