mirror of
https://github.com/denoland/deno.git
synced 2025-08-30 23:38:03 +00:00
fix(ext/http): truncate read bytes when streaming bodies (#14389)
stream shutdown wasn't happening correctly (moved it to call op_http_shutdown) & extra zeroed bytes were being sent for when body length not a multiple of 64*1024
This commit is contained in:
parent
c0e3b6096d
commit
609c359dd4
3 changed files with 35 additions and 20 deletions
|
@ -729,7 +729,9 @@ async fn op_http_write_resource(
|
|||
}
|
||||
}
|
||||
HttpResponseWriter::BodyUncompressed(body) => {
|
||||
if let Err(err) = body.send_data(Bytes::from(buf.to_temp())).await {
|
||||
let mut buf = buf.to_temp();
|
||||
buf.truncate(nread);
|
||||
if let Err(err) = body.send_data(Bytes::from(buf)).await {
|
||||
assert!(err.is_closed());
|
||||
// Pull up the failure associated with the transport connection instead.
|
||||
http_stream.conn.closed().await?;
|
||||
|
@ -740,19 +742,6 @@ async fn op_http_write_resource(
|
|||
_ => unreachable!(),
|
||||
};
|
||||
}
|
||||
|
||||
let wr = take(&mut *wr);
|
||||
if let HttpResponseWriter::Body(mut body_writer) = wr {
|
||||
match body_writer.shutdown().await {
|
||||
Ok(_) => {}
|
||||
Err(err) => {
|
||||
assert_eq!(err.kind(), std::io::ErrorKind::BrokenPipe);
|
||||
// Don't return "broken pipe", that's an implementation detail.
|
||||
// Pull up the failure associated with the transport connection instead.
|
||||
http_stream.conn.closed().await?;
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue