Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check value of X-RI header before sending next request #122

Closed
1 task done
Tracked by #120
judith-bourque opened this issue Jun 14, 2023 · 0 comments · Fixed by #123
Closed
1 task done
Tracked by #120

Check value of X-RI header before sending next request #122

judith-bourque opened this issue Jun 14, 2023 · 0 comments · Fixed by #123
Assignees
Labels
enhancement New feature or request

Comments

@judith-bourque
Copy link
Member

judith-bourque commented Jun 14, 2023

Issue

#120

Proposed solution

"The returned HTTP header X-Rl contains the number of requests remaining in the current rate limit window. X-Ttl contains the seconds until the limit is reset.

Your implementation should always check the value of the X-Rl header, and if its is 0 you must not send any more requests for the duration of X-Ttl in seconds." (source)

Headers:

  • X-Rl: Number of requests remaining in current rate limit window
  • X-Ttl: seconds until limit is reset

Steps:

  • Add sleep to get_location()
# Pseudocode
if (resp$X-RI == 0) {
    sys.sleep(resp$X-Ttl seconds)
}
# Relevant code
httr2::resp_header(resp, "X-Rl")
httr2::resp_header(resp, "X-Ttl")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant