fix(http1): ending close-delimited body should close (#2322)
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
This commit is contained in:
@@ -592,6 +592,7 @@ where
|
|||||||
pub fn end_body(&mut self) -> Result<()> {
|
pub fn end_body(&mut self) -> Result<()> {
|
||||||
debug_assert!(self.can_write_body());
|
debug_assert!(self.can_write_body());
|
||||||
|
|
||||||
|
let mut res = Ok(());
|
||||||
let state = match self.state.writing {
|
let state = match self.state.writing {
|
||||||
Writing::Body(ref mut encoder) => {
|
Writing::Body(ref mut encoder) => {
|
||||||
// end of stream, that means we should try to eof
|
// end of stream, that means we should try to eof
|
||||||
@@ -600,16 +601,17 @@ where
|
|||||||
if let Some(end) = end {
|
if let Some(end) = end {
|
||||||
self.io.buffer(end);
|
self.io.buffer(end);
|
||||||
}
|
}
|
||||||
if encoder.is_last() {
|
if encoder.is_last() || encoder.is_close_delimited() {
|
||||||
Writing::Closed
|
Writing::Closed
|
||||||
} else {
|
} else {
|
||||||
Writing::KeepAlive
|
Writing::KeepAlive
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(_not_eof) => {
|
Err(_not_eof) => {
|
||||||
return Err(crate::Error::new_user_body(
|
res = Err(crate::Error::new_user_body(
|
||||||
crate::Error::new_body_write_aborted(),
|
crate::Error::new_body_write_aborted(),
|
||||||
))
|
));
|
||||||
|
Writing::Closed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -617,7 +619,7 @@ where
|
|||||||
};
|
};
|
||||||
|
|
||||||
self.state.writing = state;
|
self.state.writing = state;
|
||||||
Ok(())
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
// When we get a parse error, depending on what side we are, we might be able
|
// When we get a parse error, depending on what side we are, we might be able
|
||||||
|
|||||||
@@ -81,6 +81,13 @@ impl Encoder {
|
|||||||
self.is_last
|
self.is_last
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_close_delimited(&self) -> bool {
|
||||||
|
match self.kind {
|
||||||
|
Kind::CloseDelimited => true,
|
||||||
|
_ => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn end<B>(&self) -> Result<Option<EncodedBuf<B>>, NotEof> {
|
pub fn end<B>(&self) -> Result<Option<EncodedBuf<B>>, NotEof> {
|
||||||
match self.kind {
|
match self.kind {
|
||||||
Kind::Length(0) => Ok(None),
|
Kind::Length(0) => Ok(None),
|
||||||
|
|||||||
Reference in New Issue
Block a user