mirror of
https://github.com/actix/actix-web.git
synced 2024-12-22 08:07:18 +00:00
check if close code exists before reading it
This commit is contained in:
parent
9880a95603
commit
5528cf62f0
1 changed files with 8 additions and 4 deletions
|
@ -310,10 +310,14 @@ where
|
||||||
}
|
}
|
||||||
OpCode::Close => {
|
OpCode::Close => {
|
||||||
self.closed = true;
|
self.closed = true;
|
||||||
let code = NetworkEndian::read_uint(payload.as_ref(), 2) as u16;
|
let close_code = if payload.len() >= 2{
|
||||||
Ok(Async::Ready(Some(Message::Close(CloseCode::from(
|
let raw_code = NetworkEndian::read_uint(payload.as_ref(), 2) as u16;
|
||||||
code,
|
CloseCode::from(raw_code)
|
||||||
)))))
|
}else{
|
||||||
|
CloseCode::Status
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(Async::Ready(Some(Message::Close(close_code))))
|
||||||
}
|
}
|
||||||
OpCode::Ping => Ok(Async::Ready(Some(Message::Ping(
|
OpCode::Ping => Ok(Async::Ready(Some(Message::Ping(
|
||||||
String::from_utf8_lossy(payload.as_ref()).into(),
|
String::from_utf8_lossy(payload.as_ref()).into(),
|
||||||
|
|
Loading…
Reference in a new issue