This is a simple class can be used to serve files for download limiting the transfer rate to a given threshold.
The class can serve a given file generating content-type header according to the file name extension. The content-length header is set to file size.
The class serves the file in chunks. It calculates the size of each chunk according to the configured download speed. After serving a chunk, the class waits for one second to make sure the download speed does not exceed the desired speed limit. |