Skip to content

Commit a37dd44

Browse files
committed
Add rewind-bug example.
1 parent 7ddb331 commit a37dd44

File tree

3 files changed

+132
-0
lines changed

3 files changed

+132
-0
lines changed

examples/rewind-bug/config.ru

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# typed: true
2+
# frozen_string_literal: true
3+
4+
require "rack"
5+
6+
class BodyTestApp
7+
def call(env)
8+
# Get the request body
9+
body = env["rack.input"]
10+
11+
# First read
12+
body.rewind
13+
first_read = body.read
14+
15+
# Second read
16+
body.rewind
17+
second_read = body.read
18+
19+
# Response showing both reads
20+
response_body = "First read: #{first_read.inspect}\n\nSecond read: #{second_read.inspect}"
21+
22+
[200, { "Content-Type" => "text/plain" }, [response_body]]
23+
end
24+
end
25+
26+
run BodyTestApp.new
27+
28+
## Output
29+
#
30+
# ➜ curl -X POST -d "This is test data" http://localhost:9292
31+
# First read: "This is test data"
32+
#
33+
# Second read: ""%

examples/rewind-bug/gems.locked

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
PATH
2+
remote: ../..
3+
specs:
4+
protocol-rack (0.12.0)
5+
protocol-http (~> 0.43)
6+
rack (>= 1.0)
7+
8+
GEM
9+
remote: https://rubygems.org/
10+
specs:
11+
async (2.24.0)
12+
console (~> 1.29)
13+
fiber-annotation
14+
io-event (~> 1.9)
15+
metrics (~> 0.12)
16+
traces (~> 0.15)
17+
async-container (0.24.0)
18+
async (~> 2.22)
19+
async-container-supervisor (0.5.1)
20+
async-container (~> 0.22)
21+
async-service
22+
io-endpoint
23+
memory-leak (~> 0.5)
24+
async-http (0.89.0)
25+
async (>= 2.10.2)
26+
async-pool (~> 0.9)
27+
io-endpoint (~> 0.14)
28+
io-stream (~> 0.6)
29+
metrics (~> 0.12)
30+
protocol-http (~> 0.49)
31+
protocol-http1 (~> 0.30)
32+
protocol-http2 (~> 0.22)
33+
traces (~> 0.10)
34+
async-http-cache (0.4.5)
35+
async-http (~> 0.56)
36+
async-pool (0.10.3)
37+
async (>= 1.25)
38+
async-service (0.13.0)
39+
async
40+
async-container (~> 0.16)
41+
console (1.30.2)
42+
fiber-annotation
43+
fiber-local (~> 1.1)
44+
json
45+
falcon (0.51.1)
46+
async
47+
async-container (~> 0.20)
48+
async-container-supervisor (~> 0.5.0)
49+
async-http (~> 0.75)
50+
async-http-cache (~> 0.4)
51+
async-service (~> 0.10)
52+
bundler
53+
localhost (~> 1.1)
54+
openssl (~> 3.0)
55+
protocol-http (~> 0.31)
56+
protocol-rack (~> 0.7)
57+
samovar (~> 2.3)
58+
fiber-annotation (0.2.0)
59+
fiber-local (1.1.0)
60+
fiber-storage
61+
fiber-storage (1.0.1)
62+
io-endpoint (0.15.2)
63+
io-event (1.10.0)
64+
io-stream (0.6.1)
65+
json (2.11.3)
66+
localhost (1.5.0)
67+
mapping (1.1.3)
68+
memory-leak (0.5.2)
69+
metrics (0.12.2)
70+
openssl (3.3.0)
71+
protocol-hpack (1.5.1)
72+
protocol-http (0.50.1)
73+
protocol-http1 (0.34.0)
74+
protocol-http (~> 0.22)
75+
protocol-http2 (0.22.1)
76+
protocol-hpack (~> 1.4)
77+
protocol-http (~> 0.47)
78+
rack (2.2.14)
79+
samovar (2.3.0)
80+
console (~> 1.0)
81+
mapping (~> 1.0)
82+
traces (0.15.2)
83+
84+
PLATFORMS
85+
arm64-darwin-24
86+
ruby
87+
88+
DEPENDENCIES
89+
falcon
90+
protocol-rack!
91+
rack (~> 2.2)
92+
93+
BUNDLED WITH
94+
2.6.2

examples/rewind-bug/gems.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
source "https://rubygems.org"
2+
3+
gem "rack", "~> 2.2"
4+
gem "protocol-rack", path: "../.."
5+
gem "falcon"

0 commit comments

Comments
 (0)