Skip to content

Commit b101b98

Browse files
committed
No stream
1 parent b105a47 commit b101b98

File tree

1 file changed

+10
-3
lines changed
  • turbopack/crates/turbopack-dev-server/src

1 file changed

+10
-3
lines changed

turbopack/crates/turbopack-dev-server/src/http.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::io::Cursor;
2+
13
use anyhow::{Result, anyhow};
24
use auto_hash_map::AutoSet;
35
use futures::{StreamExt, TryStreamExt};
@@ -94,7 +96,8 @@ pub async fn process_request_with_content_source(
9496
Some("get_from_source_operation"),
9597
)
9698
.await?;
97-
match &*resolved_result.await? {
99+
let result = resolved_result.await?;
100+
match &*result {
98101
GetFromSourceResult::Static {
99102
content,
100103
status_code,
@@ -172,11 +175,15 @@ pub async fn process_request_with_content_source(
172175
}
173176

174177
let content = file.content();
178+
// We already have all the bytes in memory
179+
let content = content.to_bytes()?.into_owned();
175180
let response = if should_compress {
176181
header_map.insert(CONTENT_ENCODING, HeaderValue::from_static("gzip"));
177182

178183
// Grab ropereader stream, coerce anyhow::Error to std::io::Error
179-
let stream_ext = content.read().into_stream().map_err(std::io::Error::other);
184+
let stream_ext = ReaderStream::new(Cursor::new(content))
185+
.into_stream()
186+
.map_err(std::io::Error::other);
180187

181188
let gzipped_stream =
182189
ReaderStream::new(async_compression::tokio::bufread::GzipEncoder::new(
@@ -190,7 +197,7 @@ pub async fn process_request_with_content_source(
190197
hyper::header::HeaderValue::try_from(content.len().to_string())?,
191198
);
192199

193-
response.body(hyper::Body::wrap_stream(ReaderStream::new(content.read())))?
200+
response.body(hyper::Body::from(content))?
194201
};
195202

196203
return Ok((response, side_effects));

0 commit comments

Comments
 (0)