mirror of
https://github.com/actix/actix-web.git
synced 2024-12-23 00:26:34 +00:00
Fix streaming response with body compression
This commit is contained in:
parent
76d790425f
commit
2159158c30
3 changed files with 28 additions and 2 deletions
|
@ -2,7 +2,9 @@
|
|||
|
||||
## 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)
|
||||
|
|
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 handler::{AsyncResult, Handler, Responder, RouteHandler, WrapHandler};
|
||||
use header;
|
||||
use http::{HttpRange, Method, StatusCode};
|
||||
use http::{HttpRange, Method, StatusCode, ContentEncoding};
|
||||
use httpmessage::HttpMessage;
|
||||
use httprequest::HttpRequest;
|
||||
use httpresponse::HttpResponse;
|
||||
|
@ -300,6 +300,7 @@ impl Responder for NamedFile {
|
|||
if let Ok(rangesvec) = HttpRange::parse(rangesheader, length) {
|
||||
length = rangesvec[0].length;
|
||||
offset = rangesvec[0].start;
|
||||
resp.content_encoding(ContentEncoding::Identity);
|
||||
resp.header(
|
||||
header::CONTENT_RANGE,
|
||||
format!(
|
||||
|
@ -898,6 +899,7 @@ mod tests {
|
|||
let request = srv
|
||||
.get()
|
||||
.uri(srv.url("/t%65st/tests/test.binary"))
|
||||
.no_default_headers()
|
||||
.finish()
|
||||
.unwrap();
|
||||
|
||||
|
@ -911,6 +913,23 @@ mod tests {
|
|||
.unwrap();
|
||||
|
||||
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]
|
||||
|
|
|
@ -505,6 +505,11 @@ impl ContentEncoder {
|
|||
}
|
||||
TransferEncoding::eof(buf)
|
||||
} else {
|
||||
if !(encoding == ContentEncoding::Identity
|
||||
|| encoding == ContentEncoding::Auto)
|
||||
{
|
||||
resp.headers_mut().remove(CONTENT_LENGTH);
|
||||
}
|
||||
ContentEncoder::streaming_encoding(buf, version, resp)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue