mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-23 16:21:06 +01:00
fix: Consume complete message body even on error
This commit is contained in:
parent
b52e77beb4
commit
7da7390f3a
@ -23,6 +23,7 @@
|
||||
- Always remove port from return value of `ConnectionInfo::realip_remote_addr()` when handling IPv6 addresses. from the `Forwarded` header.
|
||||
- The `UrlencodedError::ContentType` variant (relevant to the `Form` extractor) now uses the 415 (Media Type Unsupported) status code in it's `ResponseError` implementation.
|
||||
- Apply `HttpServer::max_connection_rate()` setting when using rustls v0.22 or v0.23.
|
||||
- Always consume complete HTTP message body, even on error
|
||||
|
||||
## 4.7.0
|
||||
|
||||
|
@ -417,24 +417,23 @@ impl Future for HttpMessageBody {
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
let this = self.get_mut();
|
||||
|
||||
if let Some(err) = this.err.take() {
|
||||
return Poll::Ready(Err(err));
|
||||
}
|
||||
while let Some(chunk) = ready!(Pin::new(&mut this.stream).poll_next(cx)) {
|
||||
if this.err.is_some() {
|
||||
continue;
|
||||
}
|
||||
|
||||
loop {
|
||||
let res = ready!(Pin::new(&mut this.stream).poll_next(cx));
|
||||
match res {
|
||||
Some(chunk) => {
|
||||
let chunk = chunk?;
|
||||
if this.buf.len() + chunk.len() > this.limit {
|
||||
return Poll::Ready(Err(PayloadError::Overflow));
|
||||
} else {
|
||||
this.buf.extend_from_slice(&chunk);
|
||||
}
|
||||
}
|
||||
None => return Poll::Ready(Ok(this.buf.split().freeze())),
|
||||
let chunk = chunk?;
|
||||
if this.buf.len() + chunk.len() > this.limit {
|
||||
this.err = Some(PayloadError::Overflow);
|
||||
} else {
|
||||
this.buf.extend_from_slice(&chunk);
|
||||
}
|
||||
}
|
||||
|
||||
Poll::Ready(match this.err.take() {
|
||||
None => Ok(this.buf.split().freeze()),
|
||||
Some(err) => Err(err),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user