Skip to content

Commit 9827e8d

Browse files
committed
Call on_eos for successful streams
1 parent 635692d commit 9827e8d

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

tower-http/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
# Unreleased
9+
10+
## Fixed
11+
12+
- `on_eos` is now called even for successful responses. ([#580])
13+
14+
[#580]: https://github.com/tower-rs/tower-http/pull/580
15+
816
# 0.6.6
917

1018
## Fixed

tower-http/src/trace/future.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ where
8080
let res = res.map(|body| ResponseBody {
8181
inner: body,
8282
classify_eos: None,
83-
on_eos: None,
83+
on_eos: on_eos.zip(Some(Instant::now())),
8484
on_body_chunk,
8585
on_failure: Some(on_failure),
8686
start,

tower-http/src/trace/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ mod tests {
556556
.await
557557
.unwrap();
558558
assert_eq!(1, ON_BODY_CHUNK_COUNT.load(Ordering::SeqCst), "body chunk");
559-
assert_eq!(0, ON_EOS.load(Ordering::SeqCst), "eos");
559+
assert_eq!(1, ON_EOS.load(Ordering::SeqCst), "eos");
560560
assert_eq!(0, ON_FAILURE.load(Ordering::SeqCst), "failure");
561561
}
562562

@@ -611,7 +611,7 @@ mod tests {
611611
.await
612612
.unwrap();
613613
assert_eq!(3, ON_BODY_CHUNK_COUNT.load(Ordering::SeqCst), "body chunk");
614-
assert_eq!(0, ON_EOS.load(Ordering::SeqCst), "eos");
614+
assert_eq!(1, ON_EOS.load(Ordering::SeqCst), "eos");
615615
assert_eq!(0, ON_FAILURE.load(Ordering::SeqCst), "failure");
616616
}
617617

0 commit comments

Comments
 (0)