diff --git a/actix-web/src/response/builder.rs b/actix-web/src/response/builder.rs index 120d4c358..c454ee6da 100644 --- a/actix-web/src/response/builder.rs +++ b/actix-web/src/response/builder.rs @@ -323,6 +323,17 @@ impl HttpResponseBuilder { S: Stream> + 'static, E: Into + 'static, { + // Set mime type to application/octet-stream if it is not set + let contains_mime = if let Some(parts) = self.inner() { + parts.headers.contains_key(header::CONTENT_TYPE) + } else { + true + }; + + if !contains_mime { + self.insert_header((header::CONTENT_TYPE, mime::APPLICATION_OCTET_STREAM)); + } + self.body(BodyStream::new(stream)) }