mirror of
https://github.com/actix/actix-web.git
synced 2025-01-05 14:58:44 +00:00
ws ping and pong uses bytes #1049
This commit is contained in:
parent
42258ee289
commit
a3ce371312
3 changed files with 16 additions and 11 deletions
|
@ -78,7 +78,7 @@ actix-tls = { version = "1.0.0-alpha.3" }
|
||||||
|
|
||||||
actix-web-codegen = "0.2.0-alpha.2"
|
actix-web-codegen = "0.2.0-alpha.2"
|
||||||
actix-http = "1.0.0-alpha.4"
|
actix-http = "1.0.0-alpha.4"
|
||||||
awc = { version = "1.0.0-alpha.3", default-features = false, optional = true }
|
awc = { version = "1.0.0-alpha.4", default-features = false, optional = true }
|
||||||
|
|
||||||
bytes = "0.5.2"
|
bytes = "0.5.2"
|
||||||
derive_more = "0.99.2"
|
derive_more = "0.99.2"
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
* Websockets: Ping and Pong should have binary data #1049
|
||||||
|
|
||||||
## [1.0.0-alpha.4] - 2019-12-08
|
## [1.0.0-alpha.4] - 2019-12-08
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -13,9 +13,9 @@ pub enum Message {
|
||||||
/// Binary message
|
/// Binary message
|
||||||
Binary(Bytes),
|
Binary(Bytes),
|
||||||
/// Ping message
|
/// Ping message
|
||||||
Ping(String),
|
Ping(Bytes),
|
||||||
/// Pong message
|
/// Pong message
|
||||||
Pong(String),
|
Pong(Bytes),
|
||||||
/// Close message with optional reason
|
/// Close message with optional reason
|
||||||
Close(Option<CloseReason>),
|
Close(Option<CloseReason>),
|
||||||
/// No-op. Useful for actix-net services
|
/// No-op. Useful for actix-net services
|
||||||
|
@ -30,9 +30,9 @@ pub enum Frame {
|
||||||
/// Binary frame
|
/// Binary frame
|
||||||
Binary(Option<BytesMut>),
|
Binary(Option<BytesMut>),
|
||||||
/// Ping message
|
/// Ping message
|
||||||
Ping(String),
|
Ping(Bytes),
|
||||||
/// Pong message
|
/// Pong message
|
||||||
Pong(String),
|
Pong(Bytes),
|
||||||
/// Close message with optional reason
|
/// Close message with optional reason
|
||||||
Close(Option<CloseReason>),
|
Close(Option<CloseReason>),
|
||||||
}
|
}
|
||||||
|
@ -119,17 +119,17 @@ impl Decoder for Codec {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
OpCode::Ping => {
|
OpCode::Ping => {
|
||||||
if let Some(ref pl) = payload {
|
if let Some(pl) = payload {
|
||||||
Ok(Some(Frame::Ping(String::from_utf8_lossy(pl).into())))
|
Ok(Some(Frame::Ping(pl.freeze())))
|
||||||
} else {
|
} else {
|
||||||
Ok(Some(Frame::Ping(String::new())))
|
Ok(Some(Frame::Ping(Bytes::new())))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
OpCode::Pong => {
|
OpCode::Pong => {
|
||||||
if let Some(ref pl) = payload {
|
if let Some(pl) = payload {
|
||||||
Ok(Some(Frame::Pong(String::from_utf8_lossy(pl).into())))
|
Ok(Some(Frame::Pong(pl.freeze())))
|
||||||
} else {
|
} else {
|
||||||
Ok(Some(Frame::Pong(String::new())))
|
Ok(Some(Frame::Pong(Bytes::new())))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
OpCode::Binary => Ok(Some(Frame::Binary(payload))),
|
OpCode::Binary => Ok(Some(Frame::Binary(payload))),
|
||||||
|
|
Loading…
Reference in a new issue