Skip to content

Commit

Permalink
Future proof by ignoring text frames
Browse files Browse the repository at this point in the history
  • Loading branch information
aqrln committed Jan 16, 2025
1 parent eeba3e5 commit 79a74dd
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions quaint/src/connector/postgres/native/websocket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,13 @@ impl Stream for WsBytesStream {
Poll::Pending => Poll::Pending,
Poll::Ready(None) => Poll::Ready(None),
Poll::Ready(Some(Ok(msg))) => match msg {
Message::Binary(b) => Poll::Ready(Some(Ok(b))),
Message::Binary(data) => Poll::Ready(Some(Ok(data))),
Message::Close(_) => Poll::Ready(None),
Message::Text(_) => Poll::Ready(Some(Err(IoError::new(
IoErrorKind::Other,
"TCP tunneling requires binary frames, got text",
)))),
Message::Text(data) => {
tracing::warn!(%data, "unexpected text frame in a WebSocket tunnel");
cx.waker().wake_by_ref();
Poll::Pending
}
Message::Ping(_) | Message::Pong(_) => {
cx.waker().wake_by_ref();
Poll::Pending
Expand Down

0 comments on commit 79a74dd

Please sign in to comment.