QuestionQ256

Using APIs

Question Image

Refer to the exhibit. Which line of code should replace the missing code in the snippet to provide API rate limiting for the requests?

  • A int(self.response.headers.post('Retry-After'))
  • B int(self.response.headers.get('Retry-After'))
  • C int(response.headers.post('Retry-After'))
  • D int(response.headers.get('Retry-After'))
Explanation

The Retry-After response header specifies how long a client should wait before retrying after HTTP status code 429. self.response.headers.get('Retry-After') retrieves that header from the response object used by the code, and int(...) converts the wait value to seconds.

Community Discussion

No comments yet. Be the first to start the discussion!