Skip to content

Commit

Permalink
Remove Content-Length header when using a compression filter
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandre Kirszenberg authored and seanmonstar committed May 18, 2020
1 parent f9e9be2 commit c983a2d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/filters/compression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

use async_compression::stream::{BrotliEncoder, DeflateEncoder, GzipEncoder};
use http::header::HeaderValue;
use hyper::{header::CONTENT_ENCODING, Body};
use hyper::{
header::{CONTENT_ENCODING, CONTENT_LENGTH},
Body,
};

use crate::filter::{Filter, WrapSealed};
use crate::reject::IsReject;
Expand Down Expand Up @@ -58,6 +61,7 @@ pub fn gzip() -> Compression<impl Fn(CompressionProps) -> Response + Copy> {
.head
.headers
.append(CONTENT_ENCODING, CompressionAlgo::GZIP.into());
props.head.headers.remove(CONTENT_LENGTH);
Response::from_parts(props.head, body)
};
Compression { func }
Expand All @@ -83,6 +87,7 @@ pub fn deflate() -> Compression<impl Fn(CompressionProps) -> Response + Copy> {
.head
.headers
.append(CONTENT_ENCODING, CompressionAlgo::DEFLATE.into());
props.head.headers.remove(CONTENT_LENGTH);
Response::from_parts(props.head, body)
};
Compression { func }
Expand All @@ -108,6 +113,7 @@ pub fn brotli() -> Compression<impl Fn(CompressionProps) -> Response + Copy> {
.head
.headers
.append(CONTENT_ENCODING, CompressionAlgo::BR.into());
props.head.headers.remove(CONTENT_LENGTH);
Response::from_parts(props.head, body)
};
Compression { func }
Expand Down

0 comments on commit c983a2d

Please sign in to comment.