BigNocciolino / CryptoTracker

Integration for Home Assistant to implement a crypto tracking system
23 stars 4 forks source link

Skip responses with bad error codes #18

Closed BigNocciolino closed 2 years ago

BigNocciolino commented 2 years ago

Error

According to MDN the header of a 429 error code response shuld contain a parameter like Retry-After: 3600 that indicates the time to wait before performing another request.

But in the header of the api there is no parameter like this, so we dont know how much time wait before we culd perform another request.

The header of the request with bad error code:

{
   "Date":"Thu, 03 Feb 2022 17:23:53 GMT",
   "Content-Type":"text/html",
   "Transfer-Encoding":"chunked",
   "Connection":"keep-alive",
   "CF-Cache-Status":"DYNAMIC",
   "Expect-CT":"max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\"",
   "Server":"cloudflare",
   "CF-RAY":"6d7d5980da0ad43b-BUD"
}

How i resolved (at least i tryed)

So instead of waiting before performing antoher request, i created a bypass when the request return a bad error code.

The sensor will update it's state only if the request code is right.