Skip to content

Commit

Permalink
Avoid double-wrapping 'StreamReadFailed' errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
SabrinaJewson authored and SergioBenitez committed Jun 3, 2023
1 parent d30e083 commit 3940c4a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ impl Stream for Field<'_> {

let state = &mut *lock;
if let Err(err) = state.buffer.poll_stream(cx) {
return Poll::Ready(Some(Err(crate::Error::StreamReadFailed(err.into()))));
return Poll::Ready(Some(Err(err)));
}

match state
Expand Down
8 changes: 2 additions & 6 deletions src/multipart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,19 +251,15 @@ impl<'r> Multipart<'r> {
return Poll::Ready(Ok(None));
}

if let Err(err) = state.buffer.poll_stream(cx) {
return Poll::Ready(Err(crate::Error::StreamReadFailed(err.into())));
}
state.buffer.poll_stream(cx)?;

if state.stage == StreamingStage::FindingFirstBoundary {
let boundary = &state.boundary;
let boundary_deriv = format!("{}{}", constants::BOUNDARY_EXT, boundary);
match state.buffer.read_to(boundary_deriv.as_bytes()) {
Some(_) => state.stage = StreamingStage::ReadingBoundary,
None => {
if let Err(err) = state.buffer.poll_stream(cx) {
return Poll::Ready(Err(crate::Error::StreamReadFailed(err.into())));
}
state.buffer.poll_stream(cx)?;
if state.buffer.eof {
return Poll::Ready(Err(crate::Error::IncompleteStream));
}
Expand Down

0 comments on commit 3940c4a

Please sign in to comment.