Check for gzip in transfer-encoding header also.
This commit is contained in:
@@ -4,7 +4,8 @@ use std::sync::{Arc, Mutex};
|
|||||||
use std::sync::atomic::{AtomicBool, Ordering};
|
use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
|
|
||||||
use hyper::client::IntoUrl;
|
use hyper::client::IntoUrl;
|
||||||
use hyper::header::{Headers, ContentType, Location, Referer, UserAgent, Accept, ContentEncoding, Encoding, ContentLength};
|
use hyper::header::{Headers, ContentType, Location, Referer, UserAgent, Accept, ContentEncoding, Encoding, ContentLength,
|
||||||
|
TransferEncoding};
|
||||||
use hyper::method::Method;
|
use hyper::method::Method;
|
||||||
use hyper::status::StatusCode;
|
use hyper::status::StatusCode;
|
||||||
use hyper::version::HttpVersion;
|
use hyper::version::HttpVersion;
|
||||||
@@ -409,23 +410,22 @@ impl Decoder {
|
|||||||
if !check_gzip {
|
if !check_gzip {
|
||||||
return Decoder::PlainText(res);
|
return Decoder::PlainText(res);
|
||||||
}
|
}
|
||||||
|
let mut is_gzip = {
|
||||||
let mut is_gzip = false;
|
res.headers.get::<ContentEncoding>().map_or(false, |encs|{
|
||||||
match res.headers.get::<ContentEncoding>() {
|
encs.contains(&Encoding::Gzip)
|
||||||
Some(encoding_types) => {
|
}) ||
|
||||||
if encoding_types.contains(&Encoding::Gzip) {
|
res.headers.get::<TransferEncoding>().map_or(false, |encs|{
|
||||||
is_gzip = true;
|
encs.contains(&Encoding::Gzip)
|
||||||
}
|
})
|
||||||
if let Some(content_length) = res.headers.get::<ContentLength>() {
|
};
|
||||||
if content_length.0 == 0 {
|
if is_gzip {
|
||||||
warn!("GZipped response with content-length of 0");
|
if let Some(content_length) = res.headers.get::<ContentLength>() {
|
||||||
is_gzip = false;
|
if content_length.0 == 0 {
|
||||||
}
|
warn!("GZipped response with content-length of 0");
|
||||||
|
is_gzip = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if is_gzip {
|
if is_gzip {
|
||||||
return Decoder::Gzip {
|
return Decoder::Gzip {
|
||||||
status: res.status.clone(),
|
status: res.status.clone(),
|
||||||
|
|||||||
Reference in New Issue
Block a user