mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
Add initialization for compresison stream.
This commit is contained in:
parent
b0f974fbfd
commit
2e4944cc26
1 changed files with 9 additions and 1 deletions
|
@ -295,6 +295,7 @@ pub struct HttpStreamResource {
|
|||
wr: AsyncRefCell<HttpResponseWriter>,
|
||||
accept_encoding: RefCell<Encoding>,
|
||||
cancel_handle: CancelHandle,
|
||||
stream_encoder: RefCell<Option<GzEncoder<Vec<u8>>>>,
|
||||
}
|
||||
|
||||
impl HttpStreamResource {
|
||||
|
@ -309,6 +310,7 @@ impl HttpStreamResource {
|
|||
wr: HttpResponseWriter::Headers(response_tx).into(),
|
||||
accept_encoding: RefCell::new(Encoding::Identity),
|
||||
cancel_handle: CancelHandle::new(),
|
||||
stream_encoder: RefCell::new(None),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -647,7 +649,13 @@ async fn op_http_write_headers(
|
|||
None => {
|
||||
// If no buffer was passed, the caller will stream the response body.
|
||||
|
||||
// TODO(@kitsonk) had compression for streamed bodies.
|
||||
match *stream.accept_encoding.borrow() {
|
||||
Encoding::Gzip => {
|
||||
builder = builder.header("content-encoding", "gzip");
|
||||
*stream.stream_encoder.borrow_mut() = Some(GzEncoder::new(Vec::new(), Compression::new(1)));
|
||||
}
|
||||
_ => {},
|
||||
}
|
||||
|
||||
// Set the user provided ETag & Vary headers for a streaming response
|
||||
if let Some(value) = etag_header {
|
||||
|
|
Loading…
Reference in a new issue