mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-24 00:21:08 +01:00
Fix streaming response with body compression
This commit is contained in:
parent
76d790425f
commit
2159158c30
@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
## 0.6.9 (2018-05-22)
|
## 0.6.9 (2018-05-22)
|
||||||
|
|
||||||
* Drop connection if request's payload is not fulle consumed #236
|
* Drop connection if request's payload is not fully consumed #236
|
||||||
|
|
||||||
|
* Fix streaming response with body compression
|
||||||
|
|
||||||
|
|
||||||
## 0.6.8 (2018-05-20)
|
## 0.6.8 (2018-05-20)
|
||||||
|
21
src/fs.rs
21
src/fs.rs
@ -20,7 +20,7 @@ use mime_guess::{get_mime_type, guess_mime_type};
|
|||||||
use error::Error;
|
use error::Error;
|
||||||
use handler::{AsyncResult, Handler, Responder, RouteHandler, WrapHandler};
|
use handler::{AsyncResult, Handler, Responder, RouteHandler, WrapHandler};
|
||||||
use header;
|
use header;
|
||||||
use http::{HttpRange, Method, StatusCode};
|
use http::{HttpRange, Method, StatusCode, ContentEncoding};
|
||||||
use httpmessage::HttpMessage;
|
use httpmessage::HttpMessage;
|
||||||
use httprequest::HttpRequest;
|
use httprequest::HttpRequest;
|
||||||
use httpresponse::HttpResponse;
|
use httpresponse::HttpResponse;
|
||||||
@ -300,6 +300,7 @@ impl Responder for NamedFile {
|
|||||||
if let Ok(rangesvec) = HttpRange::parse(rangesheader, length) {
|
if let Ok(rangesvec) = HttpRange::parse(rangesheader, length) {
|
||||||
length = rangesvec[0].length;
|
length = rangesvec[0].length;
|
||||||
offset = rangesvec[0].start;
|
offset = rangesvec[0].start;
|
||||||
|
resp.content_encoding(ContentEncoding::Identity);
|
||||||
resp.header(
|
resp.header(
|
||||||
header::CONTENT_RANGE,
|
header::CONTENT_RANGE,
|
||||||
format!(
|
format!(
|
||||||
@ -898,6 +899,7 @@ mod tests {
|
|||||||
let request = srv
|
let request = srv
|
||||||
.get()
|
.get()
|
||||||
.uri(srv.url("/t%65st/tests/test.binary"))
|
.uri(srv.url("/t%65st/tests/test.binary"))
|
||||||
|
.no_default_headers()
|
||||||
.finish()
|
.finish()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@ -911,6 +913,23 @@ mod tests {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
assert_eq!(contentlength, "100");
|
assert_eq!(contentlength, "100");
|
||||||
|
|
||||||
|
// chunked
|
||||||
|
let request = srv
|
||||||
|
.get()
|
||||||
|
.uri(srv.url("/t%65st/tests/test.binary"))
|
||||||
|
.finish()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let response = srv.execute(request.send()).unwrap();
|
||||||
|
|
||||||
|
let te = response
|
||||||
|
.headers()
|
||||||
|
.get(header::TRANSFER_ENCODING)
|
||||||
|
.unwrap()
|
||||||
|
.to_str()
|
||||||
|
.unwrap();
|
||||||
|
assert_eq!(te, "chunked");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -505,6 +505,11 @@ impl ContentEncoder {
|
|||||||
}
|
}
|
||||||
TransferEncoding::eof(buf)
|
TransferEncoding::eof(buf)
|
||||||
} else {
|
} else {
|
||||||
|
if !(encoding == ContentEncoding::Identity
|
||||||
|
|| encoding == ContentEncoding::Auto)
|
||||||
|
{
|
||||||
|
resp.headers_mut().remove(CONTENT_LENGTH);
|
||||||
|
}
|
||||||
ContentEncoder::streaming_encoding(buf, version, resp)
|
ContentEncoder::streaming_encoding(buf, version, resp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user