mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-28 01:32:57 +01:00
do not drop content-encoding header in case of identity #363
This commit is contained in:
parent
9070d59ea8
commit
185e710dc8
@ -199,7 +199,10 @@ impl<T: AsyncWrite, H: 'static> Writer for H1Writer<T, H> {
|
|||||||
let mut buf = &mut *(buffer.bytes_mut() as *mut [u8]);
|
let mut buf = &mut *(buffer.bytes_mut() as *mut [u8]);
|
||||||
for (key, value) in msg.headers() {
|
for (key, value) in msg.headers() {
|
||||||
match *key {
|
match *key {
|
||||||
TRANSFER_ENCODING | CONTENT_ENCODING => continue,
|
TRANSFER_ENCODING => continue,
|
||||||
|
CONTENT_ENCODING => if encoding != ContentEncoding::Identity {
|
||||||
|
continue;
|
||||||
|
},
|
||||||
CONTENT_LENGTH => match info.length {
|
CONTENT_LENGTH => match info.length {
|
||||||
ResponseLength::None => (),
|
ResponseLength::None => (),
|
||||||
_ => continue,
|
_ => continue,
|
||||||
|
@ -470,6 +470,39 @@ fn test_body_chunked_explicit() {
|
|||||||
assert_eq!(Bytes::from(dec), Bytes::from_static(STR.as_ref()));
|
assert_eq!(Bytes::from(dec), Bytes::from_static(STR.as_ref()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_body_identity() {
|
||||||
|
let mut e = DeflateEncoder::new(Vec::new(), Compression::default());
|
||||||
|
e.write_all(STR.as_ref()).unwrap();
|
||||||
|
let enc = e.finish().unwrap();
|
||||||
|
let enc2 = enc.clone();
|
||||||
|
|
||||||
|
let mut srv = test::TestServer::new(move |app| {
|
||||||
|
let enc3 = enc2.clone();
|
||||||
|
app.handler(move |_| {
|
||||||
|
HttpResponse::Ok()
|
||||||
|
.content_encoding(http::ContentEncoding::Identity)
|
||||||
|
.header(http::header::CONTENT_ENCODING, "deflate")
|
||||||
|
.body(enc3.clone())
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
// client request
|
||||||
|
let request = srv
|
||||||
|
.get()
|
||||||
|
.header("accept-encoding", "deflate")
|
||||||
|
.finish()
|
||||||
|
.unwrap();
|
||||||
|
let response = srv.execute(request.send()).unwrap();
|
||||||
|
assert!(response.status().is_success());
|
||||||
|
|
||||||
|
// read response
|
||||||
|
let bytes = srv.execute(response.body()).unwrap();
|
||||||
|
|
||||||
|
// decode deflate
|
||||||
|
assert_eq!(bytes, Bytes::from(STR));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_body_deflate() {
|
fn test_body_deflate() {
|
||||||
let mut srv = test::TestServer::new(|app| {
|
let mut srv = test::TestServer::new(|app| {
|
||||||
|
Loading…
Reference in New Issue
Block a user