Sets the status code for our response. :arg int status_code: Response status code. :arg str reason: Human-readable reason phrase describing the status code. If ``None``, it will be filled in from `http.client.responses` or "Unknown". .. versionchange
(self, status_code: int, reason: Optional[str] = None)
| 347 | pass |
| 348 | |
| 349 | def set_status(self, status_code: int, reason: Optional[str] = None) -> None: |
| 350 | """Sets the status code for our response. |
| 351 | |
| 352 | :arg int status_code: Response status code. |
| 353 | :arg str reason: Human-readable reason phrase describing the status |
| 354 | code. If ``None``, it will be filled in from |
| 355 | `http.client.responses` or "Unknown". |
| 356 | |
| 357 | .. versionchanged:: 5.0 |
| 358 | |
| 359 | No longer validates that the response code is in |
| 360 | `http.client.responses`. |
| 361 | """ |
| 362 | self._status_code = status_code |
| 363 | if reason is not None: |
| 364 | self._reason = escape.native_str(reason) |
| 365 | else: |
| 366 | self._reason = httputil.responses.get(status_code, "Unknown") |
| 367 | |
| 368 | def get_status(self) -> int: |
| 369 | """Returns the status code for our response.""" |