Skip to content

Commit

Permalink
gzip: examine Content-Length header before removing
Browse files Browse the repository at this point in the history
  • Loading branch information
jsha committed Jan 3, 2023
1 parent 78ec3a4 commit cd86337
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 2.6.1

## Fixed
* gzip: examine Content-Length header before removing

# 2.6.0

## Added
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ureq"
version = "2.6.0"
version = "2.6.1"
authors = ["Martin Algesten <martin@algesten.se>", "Jacob Hoffman-Andrews <ureq@hoffman-andrews.com>"]
description = "Simple, safe HTTP client"
license = "MIT/Apache-2.0"
Expand Down
3 changes: 2 additions & 1 deletion src/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -566,12 +566,13 @@ impl Response {
let compression =
get_header(&headers, "content-encoding").and_then(Compression::from_header_value);

let body_type = Self::body_type(&unit.method, status, http_version, &headers);

// remove Content-Encoding and length due to automatic decompression
if compression.is_some() {
headers.retain(|h| !h.is_name("content-encoding") && !h.is_name("content-length"));
}

let body_type = Self::body_type(&unit.method, status, http_version, &headers);
let reader = Self::stream_to_reader(stream, &unit, body_type, compression);

let url = unit.url.clone();
Expand Down

0 comments on commit cd86337

Please sign in to comment.