rateLimited function

Response rateLimited(
  1. DateTime reset
)

A primary rate-limit refusal: quota exhausted until reset.

The distinguishing header is x-ratelimit-remaining: 0 — that is what tells the policy to wait for the reset rather than back off exponentially, and it is why a 403 here is a wait while a 403 without it is an authorization failure.

Implementation

http.Response rateLimited(DateTime reset) => http.Response(
      jsonEncode({
        'message': 'API rate limit exceeded',
        'documentation_url': 'https://docs.github.com/rest/rate-limit',
      }),
      403,
      headers: {
        'content-type': 'application/json',
        'x-ratelimit-remaining': '0',
        'x-ratelimit-reset':
            '${reset.toUtc().millisecondsSinceEpoch ~/ 1000}',
      },
    );