diff --git a/docs/dsl/body.md b/docs/dsl/body.md index 7cedab6ce9..3727c5c53a 100644 --- a/docs/dsl/body.md +++ b/docs/dsl/body.md @@ -59,13 +59,13 @@ To create an `Body` that encodes a Stream you can use `Body.fromStream`. - Using a Stream of Bytes ```scala mdoc:silent - val streamHttpData1: Body = Body.fromStream(ZStream.fromChunk(Chunk.fromArray("Some String".getBytes(Charsets.Http)))) + val streamHttpData1: Body = Body.fromStreamChunked(ZStream.fromChunk(Chunk.fromArray("Some String".getBytes(Charsets.Http)))) ``` - Using a Stream of String ```scala mdoc:silent - val streamHttpData2: Body = Body.fromCharSequenceStream(ZStream("a", "b", "c"), Charsets.Http) + val streamHttpData2: Body = Body.fromCharSequenceStreamChunked(ZStream("a", "b", "c"), Charsets.Http) ``` ### Creating a Body from a `File` @@ -73,5 +73,5 @@ To create an `Body` that encodes a Stream you can use `Body.fromStream`. To create an `Body` that encodes a File you can use `Body.fromFile`: ```scala mdoc:silent:crash - val fileHttpData: Body = Body.fromFile(new java.io.File(getClass.getResource("/fileName.txt").getPath)) + val fileHttpData: ZIO[Any, Nothing, Body] = Body.fromFile(new java.io.File(getClass.getResource("/fileName.txt").getPath)) ``` diff --git a/docs/dsl/headers.md b/docs/dsl/headers.md index 520e783774..2cdcc8fa32 100644 --- a/docs/dsl/headers.md +++ b/docs/dsl/headers.md @@ -88,9 +88,7 @@ object SimpleResponseDispatcher extends ZIOAppDefault { if (acceptsStreaming) Response( status = Status.Ok, - // Setting response header - headers = Headers(Header.ContentLength(message.length.toLong)), // adding CONTENT-LENGTH header - body = Body.fromStream(ZStream.fromChunk(message)), // Encoding content using a ZStream + body = Body.fromStream(ZStream.fromChunk(message), message.length.toLong), // Encoding content using a ZStream ) else { // Adding a custom header to Response diff --git a/docs/examples/advanced/streaming-file.md b/docs/examples/advanced/streaming-file.md index fb0e1b4554..2e02449e19 100644 --- a/docs/examples/advanced/streaming-file.md +++ b/docs/examples/advanced/streaming-file.md @@ -22,7 +22,7 @@ object FileStreaming extends ZIOAppDefault { // Read the file as ZStream // Uses the blocking version of ZStream.fromFile - Method.GET / "blocking" -> Handler.fromStream(ZStream.fromPath(Paths.get("README.md"))), + Method.GET / "blocking" -> Handler.fromStreamChunked(ZStream.fromPath(Paths.get("README.md"))), // Uses netty's capability to write file content to the Channel // Content-type response headers are automatically identified and added diff --git a/docs/examples/advanced/streaming-response.md b/docs/examples/advanced/streaming-response.md index 1389e67d45..c70f987b42 100644 --- a/docs/examples/advanced/streaming-response.md +++ b/docs/examples/advanced/streaming-response.md @@ -30,8 +30,7 @@ object StreamingResponse extends ZIOAppDefault { handler( http.Response( status = Status.Ok, - headers = Headers(Header.ContentLength(message.length.toLong)), - body = Body.fromStream(ZStream.fromChunk(message)), // Encoding content using a ZStream + body = Body.fromStream(ZStream.fromChunk(message), message.length.toLong), // Encoding content using a ZStream ), ), ).toHttpApp