From b2e4fcbce1fa055743c66e943a3db3ea2e454d3f Mon Sep 17 00:00:00 2001 From: Ryan Cavicchioni Date: Sun, 9 Mar 2025 15:38:34 -0500 Subject: [PATCH] add route to test chunked encoding --- app.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app.rb b/app.rb index 441aa4c..e4dcb5f 100644 --- a/app.rb +++ b/app.rb @@ -427,11 +427,14 @@ route :delete, :get, :patch, :post, :put, "/status/:code" do end get "/chunked/:delay" do + content_type "application/x-ndjson" + delay = Float(params[:delay]) stream do |out| - out << "Hello, world!\n" - sleep delay - out << "Hello, world!\n" + 30.times do |i| + out << jsonify({id: i, message: i % 2 == 0 ? "tick" : "tock"}) + sleep delay + end end end