There are several approaches to rate limiting; one of them is token
bucket, for which you can find a recipe here and another
Usually you would want to do throttling or rate limiting on
socket.recv(). You could play
socket-throttle and see if it does what you
This is not to be confused with
rate limiting response headers, which are related to a number of
requests rather than a download / transfer rate.