juancarlospaco / faster-than-requests

Faster requests on Python 3
https://gist.github.com/juancarlospaco/37da34ed13a609663f55f4466c4dbc3e
MIT License
1.09k stars 91 forks source link

Response.raise_for_status() equivalent? #187

Closed aaronmurniadi closed 2 years ago

aaronmurniadi commented 2 years ago

Hi everyone, thank you for this amazing project.

As the title describes, I am looking for Requests' response.raise_for_status() equivalent in faster_than_requests

tl;dr: It raises :class:HTTPError, if one occurred (for both client and server side errors), and returns appropriate description of it.

Thanks!

PS: My current solution is to assert the response[2] value:

def ResponseAssert(response):
    assert response[2] != "500 Internal Server Error", "500 Internal Server Error"
    assert response[2] != "404 Not Found", "404 Not Found"

But this is tedious to do for each possible error messages.

I can not use if 400 <= self.status_code < 500: and elif 500 <= self.status_code < 600: logic like what Requests did (see link above) because response[2] returns a string like 500 Internal Server Error.

Any help is very much appreciated!

github-actions[bot] commented 2 years ago

This issue is Stale because it has been open for 90 days with no activity. Contribute a fix or comment on the issue, or it will be closed in a few days.

github-actions[bot] commented 2 years ago

This issue has been marked as Stale and closed due to inactivity.