From 02ee76a2ed71f76ee5f994201921964f0f1f39fc Mon Sep 17 00:00:00 2001 From: Ethan Ruszanowski Date: Tue, 23 Jul 2024 17:09:53 -0400 Subject: [PATCH] Add chunk funciton --- src/webtest.gleam | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/webtest.gleam b/src/webtest.gleam index 21558c8..b8b24eb 100644 --- a/src/webtest.gleam +++ b/src/webtest.gleam @@ -4,6 +4,7 @@ import gleam/erlang/process import gleam/http import gleam/http/request.{type Request} import gleam/http/response.{type Response} +import gleam/int import gleam/io import gleam/iterator import gleam/option.{None, Some} @@ -84,3 +85,14 @@ fn echo_body(request: Request(Connection)) -> Response(ResponseData) { |> response.set_body(mist.Bytes(bytes_builder.new())) }) } + +fn serve_chunk(_request: Request(Connection)) -> Response(ResponseData) { + let iter = + ["one", "two", "three"] + |> iterator.from_list + |> iterator.map(bytes_builder.from_string) + + response.new(200) + |> response.set_body(mist.Chunked(iter)) + |> response.set_header("content-type", "text/plain") +}