mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-28 01:52:57 +01:00
Merge pull request #453 from DoumanAsh/reserve_status_line_for_server_error
Reserve enough space for ServerError task to write status line
This commit is contained in:
commit
16546a707f
@ -16,6 +16,9 @@ impl HttpHandlerTask for ServerError {
|
|||||||
fn poll_io(&mut self, io: &mut Writer) -> Poll<bool, Error> {
|
fn poll_io(&mut self, io: &mut Writer) -> Poll<bool, Error> {
|
||||||
{
|
{
|
||||||
let bytes = io.buffer();
|
let bytes = io.buffer();
|
||||||
|
//Buffer should have sufficient capacity for status line
|
||||||
|
//and extra space
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
io.set_date();
|
io.set_date();
|
||||||
|
@ -8,8 +8,10 @@ const DEC_DIGITS_LUT: &[u8] = b"0001020304050607080910111213141516171819\
|
|||||||
6061626364656667686970717273747576777879\
|
6061626364656667686970717273747576777879\
|
||||||
8081828384858687888990919293949596979899";
|
8081828384858687888990919293949596979899";
|
||||||
|
|
||||||
|
pub(crate) const STATUS_LINE_BUF_SIZE: usize = 13;
|
||||||
|
|
||||||
pub(crate) fn write_status_line(version: Version, mut n: u16, bytes: &mut BytesMut) {
|
pub(crate) fn write_status_line(version: Version, mut n: u16, bytes: &mut BytesMut) {
|
||||||
let mut buf: [u8; 13] = [
|
let mut buf: [u8; STATUS_LINE_BUF_SIZE] = [
|
||||||
b'H', b'T', b'T', b'P', b'/', b'1', b'.', b'1', b' ', b' ', b' ', b' ', b' ',
|
b'H', b'T', b'T', b'P', b'/', b'1', b'.', b'1', b' ', b' ', b' ', b' ', b' ',
|
||||||
];
|
];
|
||||||
match version {
|
match version {
|
||||||
|
Loading…
Reference in New Issue
Block a user