1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-06-25 06:39:22 +02:00

Do not compress NoContent (204) responses #918

This commit is contained in:
Nikolay Kim
2019-06-16 21:54:17 +06:00
parent eaa371db8b
commit 7c0f570845
4 changed files with 13 additions and 4 deletions

View File

@ -33,6 +33,7 @@ impl<B: MessageBody> Encoder<B> {
) -> ResponseBody<Encoder<B>> {
let can_encode = !(head.headers().contains_key(&CONTENT_ENCODING)
|| head.status == StatusCode::SWITCHING_PROTOCOLS
|| head.status == StatusCode::NO_CONTENT
|| encoding == ContentEncoding::Identity
|| encoding == ContentEncoding::Auto);
@ -122,6 +123,7 @@ impl<B: MessageBody> MessageBody for Encoder<B> {
Async::NotReady => return Ok(Async::NotReady),
Async::Ready(Some(chunk)) => {
if let Some(mut encoder) = self.encoder.take() {
self.encoded += chunk.len();
if chunk.len() < INPLACE {
encoder.write(&chunk)?;
let chunk = encoder.take();