Include canonical reason test for HTTP error responses.

This commit is contained in:
Robert G. Jakabosky 2018-09-01 13:24:57 +08:00
parent 3784637a56
commit c3c6a89385
1 changed files with 5 additions and 0 deletions

View File

@ -21,7 +21,12 @@ impl HttpHandlerTask for ServerError {
bytes.reserve(helpers::STATUS_LINE_BUF_SIZE + 1); bytes.reserve(helpers::STATUS_LINE_BUF_SIZE + 1);
helpers::write_status_line(self.0, self.1.as_u16(), bytes); helpers::write_status_line(self.0, self.1.as_u16(), bytes);
} }
// Convert Status Code to Reason.
let reason = self.1.canonical_reason().unwrap_or("<unknown status code>");
io.buffer().extend_from_slice(reason.as_bytes());
// No response body.
io.buffer().extend_from_slice(b"\r\ncontent-length: 0\r\n"); io.buffer().extend_from_slice(b"\r\ncontent-length: 0\r\n");
// date header
io.set_date(); io.set_date();
Ok(Async::Ready(true)) Ok(Async::Ready(true))
} }