Throttling broken for one request per time period
I recently upgraded to the latest pistons code due to a bug in the throttling decorator which appeared to be fixed. There is an off-by-one bug in latest version of the throttling decorator, which is especially apparent when limiting to 1 request per time period. See line 113 of utils.py.
If there has been no request for this resource from an IP, the count is initialized to 1. If max_requests is 1, the request is immediately throttled.
Here is an example of the first request to a piston resource with a throttle of 1 per 5 seconds:
(lincolnloop)Russ-Neufelds-MacBook-Pro: russn$ curl -iXPUT -Ffile=@./foo.txt -F email@example.com -F password=
echo -n foo | openssl sha1 http://localhost:8000/piston/test
HTTP/1.0 503 SERVICE UNAVAILABLE
Server: WSGIServer/0.1 Python/2.6.1
Vary: Authorization, Cookie
Date: Mon, 08 Mar 2010 22:19:26 GMT
Throttled, wait 5 seconds.