Skip to content

Commit

Permalink
refactor(http1): fixed style error
Browse files Browse the repository at this point in the history
  • Loading branch information
T-aian committed Nov 18, 2024
1 parent ee2dc28 commit 87d456d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
13 changes: 4 additions & 9 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,16 +240,11 @@ impl Error {

/// Returns true if the error was caused by a timeout.
pub fn is_timeout(&self) -> bool {
#[cfg(any(
all(feature = "http1", feature = "server"),
feature = "ffi"
))]
return matches!(self.inner.kind, Kind::HeaderTimeout) || self.find_source::<TimedOut>().is_some();
#[cfg(any(all(feature = "http1", feature = "server"), feature = "ffi"))]
return matches!(self.inner.kind, Kind::HeaderTimeout)
|| self.find_source::<TimedOut>().is_some();

#[cfg(not(any(
all(feature = "http1", feature = "server"),
feature = "ffi"
)))]
#[cfg(not(any(all(feature = "http1", feature = "server"), feature = "ffi")))]
self.find_source::<TimedOut>().is_some()
}

Expand Down
15 changes: 8 additions & 7 deletions tests/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2862,7 +2862,7 @@ fn http1_trailer_recv_fields() {
}

#[tokio::test]
async fn timeout_err() {
async fn http1_timeout_error() {
let (listener, addr) = setup_tcp_listener();

let j = tokio::spawn(async move {
Expand All @@ -2873,16 +2873,17 @@ async fn timeout_err() {
.timer(TokioTimer)
.header_read_timeout(Duration::from_secs(1))
.serve_connection(socket, HelloWorld)
.await {
Some(e.is_timeout())
} else {
None
}
.await
{
Some(e.is_timeout())
} else {
None
}
});

let tcp = TokioIo::new(connect_async(addr).await);
let (_client, conn) = hyper::client::conn::http1::Builder::new()
.handshake::<_,Empty<Bytes>>(tcp)
.handshake::<_, Empty<Bytes>>(tcp)
.await
.expect("http handshake");

Expand Down

0 comments on commit 87d456d

Please sign in to comment.