Skip to content

Commit e44c1ca

Browse files
committed
If a server has an I/O error writing the body, panic.
1 parent 1af6d58 commit e44c1ca

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/http/server.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -170,15 +170,13 @@ impl Finished {
170170
// it's dropped first.
171171
drop(stream);
172172

173-
if result.is_ok() {
174-
let wasi_trailers = trailers.map(|trailers| header_map_to_wasi(&trailers));
175-
176-
wasi::http::types::OutgoingBody::finish(body, wasi_trailers)
177-
.expect("body length did not match Content-Length header value");
178-
} else {
179-
// As in `fail`, there's no need to do anything else on failure.
180-
// TODO: Should we log the failure somewhere?
181-
}
173+
// If there was an I/O error, panic and don't call `OutgoingBody::finish`.
174+
let _ = result.expect("I/O error while writing the body");
175+
176+
let wasi_trailers = trailers.map(|trailers| header_map_to_wasi(&trailers));
177+
178+
wasi::http::types::OutgoingBody::finish(body, wasi_trailers)
179+
.expect("body length did not match Content-Length header value");
182180

183181
Self(())
184182
}

0 commit comments

Comments
 (0)