saguiitay / DropboxRestAPI

Dropbox REST API client in C#
MIT License
46 stars 38 forks source link

Automatic handling of HTTP error 429 Too Many Requests #12

Closed alexgen closed 9 years ago

alexgen commented 9 years ago

Dropbox may rate-limit API requests in certain conditions by responding with HTTP 429 (I believe OAuth 1.0 apps would get HTTP 503 in the same case).

It would be nice if the library would have an opt-in parameter to automatically backoff in such cases.

Here is an example response:

HTTP/1.1 429 Too Many Requests
Server: nginx
Date: Mon, 06 Apr 2015 15:16:56 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
Retry-After: 60.0

{"error": "Rate limiting oauth_accesses_per_access_token"}

As you can see, the response header includes "Retry-After" header, which indicates when it would be safe to repeat the request.

http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.37

saguiitay commented 9 years ago

See Wiki for usage