-
Notifications
You must be signed in to change notification settings - Fork 110
Description
Currently, the library does not specifically handle HTTP status codes 429 Too Many Requests and 503 Service Unavailable. When a CalDAV server (such as iCloud, Yahoo, or other rate-limited services) responds with these codes, it often includes a Retry-After header indicating how long the client should wait before retrying.
Without explicit handling, the library simply propagates the response or raises a generic exception, leaving the client application with no easy way to implement a polite retry mechanism. This can lead to unnecessary request failures, poor user experience, and even temporary bans if the client continues to hammer the server.
Proposed solution:
Intercept responses with status codes 429 and 503.
Extract the Retry-After header, which can be either an integer number of seconds or an HTTP-date string.
Parse the value accordingly and raise a new, dedicated exception (e.g., RateLimitError) that carries the parsed retry delay.
The exception class will be added to caldav.lib.error and will store the retry information (as seconds or the original string) for the caller to use.
This change is backward‑compatible: existing code that does not catch the new exception will still see an error (the request will fail), but now the failure is more informative and actionable. Applications that wish to handle rate limiting gracefully can catch RateLimitError and respect the suggested wait time.
The new behaviour aligns with common practices in HTTP client libraries and helps users of python-caldav build more robust integrations with rate‑limited CalDAV services