News for hackers. Stuff that matters.
Re:On incomplete HTTP reads and the requests library in Python by llccbb on Sunday April 22, 2018 @08:16PM (#16899524)
I agree with your point that there should be some baked in capability for a more comprehensive check on the HTTP response. There are probably some edge cases around this regarding stream=True (load header only, not content) and iter_content() which pulls chunks from a buffer so the entire content isn't loaded into memory at once. Probably surmountable.

FWIW Response.status_code is an int, so it might need to be a member function on Response.

Re:On incomplete HTTP reads and the requests library in Python by icebraining on Monday April 23, 2018 @03:42AM (#16901273)
Response.status_code is an int

No, it acts like an int; whether it is one (should be) irrelevant :)

    class StatusCode(int):
        @property
        def ok(self):
            return 200 <= self < 300