MCPcopy
hub / github.com/benoitc/gunicorn / send_error

Method send_error

gunicorn/http2/connection.py:581–594  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.

Callers 6

test_404_responseMethod · 0.95
test_500_responseMethod · 0.95
_handle_http2_requestMethod · 0.45
handle_http2Method · 0.45
handle_http2Method · 0.45

Calls 2

send_responseMethod · 0.95
encodeMethod · 0.80

Tested by 3

test_404_responseMethod · 0.76
test_500_responseMethod · 0.76