add route to test chunked encoding
This commit is contained in:
parent
86ba2e6c1a
commit
b2e4fcbce1
9
app.rb
9
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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user