Send an error response on a stream. Args: stream_id: The stream ID status_code: HTTP status code message: Optional error message body
(self, stream_id, status_code, message=None)
| 579 | return False |
| 580 | |
| 581 | def send_error(self, stream_id, status_code, message=None): |
| 582 | """Send an error response on a stream. |
| 583 | |
| 584 | Args: |
| 585 | stream_id: The stream ID |
| 586 | status_code: HTTP status code |
| 587 | message: Optional error message body |
| 588 | """ |
| 589 | body = message.encode() if message else b'' |
| 590 | headers = [('content-length', str(len(body)))] |
| 591 | if body: |
| 592 | headers.append(('content-type', 'text/plain; charset=utf-8')) |
| 593 | |
| 594 | self.send_response(stream_id, status_code, headers, body) |
| 595 | |
| 596 | def reset_stream(self, stream_id, error_code=0x8): |
| 597 | """Reset a stream with RST_STREAM. |