Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix build when http1 feature is disabled. #1002

Merged
merged 1 commit into from
Mar 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions client/src/ws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@
use futures_sink::Sink;
use http_ws::{Codec, RequestStream, WsError};

use crate::error::ErrorResponse;

use super::{
body::ResponseBody,
bytes::{Buf, BytesMut},
error::Error,
connection::Connection,
error::{Error, ErrorResponse},
http::{StatusCode, Version},
tunnel::{Leak, Tunnel, TunnelRequest, TunnelSink, TunnelStream},
};
Expand Down Expand Up @@ -125,14 +124,15 @@
inner.codec.encode(item, &mut inner.send_buf).map_err(Into::into)
}

#[allow(unreachable_code)]
fn poll_flush(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
let inner = self.get_mut();

let io = match inner.recv_stream.inner_mut() {
let _io: &mut Connection = match inner.recv_stream.inner_mut() {
#[cfg(feature = "http1")]
ResponseBody::H1(body) => &mut **body.conn(),

Check warning on line 133 in client/src/ws.rs

View workflow job for this annotation

GitHub Actions / clippy

deref which would be done by auto-deref

warning: deref which would be done by auto-deref --> client/src/ws.rs:133:39 | 133 | ResponseBody::H1(body) => &mut **body.conn(), | ^^^^^^^^^^^^^^^^^^ help: try: `body.conn()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#explicit_auto_deref = note: `#[warn(clippy::explicit_auto_deref)]` on by default

Check warning on line 133 in client/src/ws.rs

View workflow job for this annotation

GitHub Actions / clippy

deref which would be done by auto-deref

warning: deref which would be done by auto-deref --> client/src/ws.rs:133:39 | 133 | ResponseBody::H1(body) => &mut **body.conn(), | ^^^^^^^^^^^^^^^^^^ help: try: `body.conn()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#explicit_auto_deref = note: `#[warn(clippy::explicit_auto_deref)]` on by default
#[cfg(feature = "http1")]
ResponseBody::H1Owned(body) => &mut **body.conn(),

Check warning on line 135 in client/src/ws.rs

View workflow job for this annotation

GitHub Actions / clippy

deref which would be done by auto-deref

warning: deref which would be done by auto-deref --> client/src/ws.rs:135:44 | 135 | ResponseBody::H1Owned(body) => &mut **body.conn(), | ^^^^^^^^^^^^^^^^^^ help: try: `body.conn()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#explicit_auto_deref

Check warning on line 135 in client/src/ws.rs

View workflow job for this annotation

GitHub Actions / clippy

deref which would be done by auto-deref

warning: deref which would be done by auto-deref --> client/src/ws.rs:135:44 | 135 | ResponseBody::H1Owned(body) => &mut **body.conn(), | ^^^^^^^^^^^^^^^^^^ help: try: `body.conn()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#explicit_auto_deref
#[cfg(feature = "http2")]
ResponseBody::H2(body) => {
while !inner.send_buf.chunk().is_empty() {
Expand All @@ -140,13 +140,13 @@
}
return Poll::Ready(Ok(()));
}
_ => panic!("websocket can only be enabled when http1 or http2 feature is also enabled"),
_ => unimplemented!("websocket can only be enabled when http1 or http2 feature is also enabled"),
};

use std::io::{self, Write};
use xitca_io::io::{AsyncIo, Interest};

let mut io = Pin::new(io);
let mut io = Pin::new(_io);

while !inner.send_buf.chunk().is_empty() {
match io.as_mut().get_mut().write(inner.send_buf.chunk()) {
Expand Down Expand Up @@ -178,12 +178,16 @@
ResponseBody::H1(body) => {
xitca_io::io::AsyncIo::poll_shutdown(Pin::new(&mut **body.conn()), cx).map_err(Into::into)
}
#[cfg(feature = "http1")]
ResponseBody::H1Owned(body) => {
xitca_io::io::AsyncIo::poll_shutdown(Pin::new(&mut **body.conn()), cx).map_err(Into::into)
}
#[cfg(feature = "http2")]
ResponseBody::H2(body) => {
body.send_data(xitca_http::bytes::Bytes::new(), true)?;
Poll::Ready(Ok(()))
}
_ => panic!("websocket can only be enabled when http1 or http2 feature is also enabled"),
_ => unimplemented!("websocket can only be enabled when http1 or http2 feature is also enabled"),
}
}
}
Expand Down
Loading