Handle gunicorn_h1c exceptions with appropriate HTTP status codes. Returns True if the exception was handled, False otherwise.
(self, exc)
| 559 | self._body_receiver.set_complete() |
| 560 | |
| 561 | def _handle_h1c_exception(self, exc): |
| 562 | """Handle gunicorn_h1c exceptions with appropriate HTTP status codes. |
| 563 | |
| 564 | Returns True if the exception was handled, False otherwise. |
| 565 | """ |
| 566 | # pylint: disable=isinstance-second-argument-not-valid-type |
| 567 | h1c_limit_line = ASGIProtocol._h1c_limit_request_line |
| 568 | if h1c_limit_line is not None and isinstance(exc, h1c_limit_line): |
| 569 | self._send_error_response(414, str(exc)) # URI Too Long |
| 570 | self._close_transport() |
| 571 | return True |
| 572 | h1c_limit_headers = ASGIProtocol._h1c_limit_request_headers |
| 573 | if h1c_limit_headers is not None and isinstance(exc, h1c_limit_headers): |
| 574 | self._send_error_response(431, str(exc)) # Request Header Fields Too Large |
| 575 | self._close_transport() |
| 576 | return True |
| 577 | h1c_chunk_ext = ASGIProtocol._h1c_invalid_chunk_extension |
| 578 | if h1c_chunk_ext is not None and isinstance(exc, h1c_chunk_ext): |
| 579 | self._send_error_response(400, str(exc)) |
| 580 | self._close_transport() |
| 581 | return True |
| 582 | return False |
| 583 | |
| 584 | def data_received(self, data): |
| 585 | """Called when data is received on the connection.""" |
no test coverage detected