Esempio n. 1
0
 def error_response(
     self,
     formatter: Formatter,
     status_code: bytes,
     status_phrase: bytes,
     message: str,
     log_message: str = None,
 ) -> None:
     """Send an error response."""
     if self.timeout:
         self.timeout.delete()
         self.timeout = None
     self.exchange.response_start(
         status_code,
         status_phrase,
         [
             (b"Content-Type", formatter.content_type()),
             (b"Cache-Control", b"max-age=60, must-revalidate"),
         ],
     )
     formatter.start_output()
     formatter.error_output(message)
     self.exchange.response_done([])
     if log_message:
         self.error_log(log_message)