1. Jesper Noehr
  2. django-piston
  3. Issues
Issue #112 new

Throttling broken for one request per time period

russellneufeld
created an issue

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.

http://bitbucket.org/jespern/django-piston/src/tip/piston/utils.py#cl-113

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=foo@foo.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 Content-Length: 26 Vary: Authorization, Cookie Retry-After: 5 Date: Mon, 08 Mar 2010 22:19:26 GMT X-Django-User: - Content-Type: text/plain

Throttled, wait 5 seconds.

Comments (0)

  1. Log in to comment