Articles 
Treat HTTP status codes as strings
I usually see HTTP status codes being checked as integer numbers:
if ((status >= 200) && (status < 300)) // or `<= 299`
This is rather verbose. But if you think about it, it's the first digit in the number that has a special value, and there are only five of them:
- 1xx: server programmer is too smart
- 2xx: success
- 3xx: your client HTTP library is too dumb
- 4xx: you screwed up
- 5xx: server screwed up
When treated as strings, checking for the error class looks a bit better:
if (status[0] == '2')
Unfortunately, the ensuing party is pre-pooped by most client HTTP libraries helpfully casting the status to int.
Dear HTTP client libraries! Consider adding response.error_class to your responses.