This describes a minimal http response interface used by this package. :var int status_code: The status code of this http response. Our async code path would also accept an alias as "status". :var string text: The body of this http response. Our async code
| 39 | |
| 40 | |
| 41 | class Response(object): |
| 42 | """This describes a minimal http response interface used by this package. |
| 43 | |
| 44 | :var int status_code: |
| 45 | The status code of this http response. |
| 46 | |
| 47 | Our async code path would also accept an alias as "status". |
| 48 | |
| 49 | :var string text: |
| 50 | The body of this http response. |
| 51 | |
| 52 | Our async code path would also accept an awaitable with the same name. |
| 53 | """ |
| 54 | status_code = 200 # Our async code path would also accept a name as "status" |
| 55 | |
| 56 | text = "body as a string" # Our async code path would also accept an awaitable |
| 57 | # We could define a json() method instead of a text property/method, |
| 58 | # but a `text` would be more generic, |
| 59 | # when downstream packages would potentially access some XML endpoints. |
| 60 | |
| 61 | headers = {} # Duplicated headers are expected to be combined into one header |
| 62 | # with its value as a comma-separated string. |
| 63 | # https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.2 |
| 64 | # Popular HTTP libraries model it as a case-insensitive dict. |
| 65 | |
| 66 | def raise_for_status(self): |
| 67 | """Raise an exception when http response status contains error""" |
| 68 | raise NotImplementedError("Your implementation should provide this") |
| 69 | |
| 70 | |
| 71 | def _get_status_code(resp): |