# Streaming Responses
When returning large datasets or files, loading the entire payload into memory is inefficient and dangerous. Instead, you can stream the response body.
#Returning a Stream
Actix Web accepts asynchronous streams of Bytes.
code_blocksrust
use actix_web::{get, HttpResponse, Error};
use actix_web::body::SizedStream;
use futures_util::stream;
use bytes::Bytes;
#[get("/stream")]
async fn stream_data() -> HttpResponse {
let my_stream = stream::iter(vec![
Ok::<_, Error>(Bytes::from_static(b"Hello ")),
Ok::<_, Error>(Bytes::from_static(b"World!")),
]);
HttpResponse::Ok().streaming(my_stream)
}#Use Cases
Streaming is crucial for video/audio delivery, large CSV exports, and proxying data from other APIs or databases without buffering.