File tree Expand file tree Collapse file tree 1 file changed +28
-5
lines changed
test/protocol/http1/connection Expand file tree Collapse file tree 1 file changed +28
-5
lines changed Original file line number Diff line number Diff line change 9
9
describe Protocol ::HTTP1 ::Connection do
10
10
include_context ConnectionContext
11
11
12
- def before
13
- super
14
-
15
- client . stream . write ( input )
16
- client . stream . close
12
+ before do
13
+ # We use a thread here, as writing to the stream may block, e.g. if the input is big enough.
14
+ @writer = Thread . new do
15
+ client . stream . write ( input )
16
+ client . stream . close
17
+ end
18
+ end
19
+
20
+ after do
21
+ @writer . join
17
22
end
18
23
19
24
with "invalid hexadecimal content-length" do
@@ -122,4 +127,22 @@ def input
122
127
end . to raise_exception ( Protocol ::HTTP1 ::BadRequest )
123
128
end
124
129
end
130
+
131
+ with "line length exceeding the limit" do
132
+ def input
133
+ <<~HTTP . gsub ( "\n " , "\r \n " )
134
+ POST / HTTP/1.1
135
+ Host: a.com
136
+ Connection: close
137
+ Long-Header: #{ 'a' * 8192 }
138
+
139
+ HTTP
140
+ end
141
+
142
+ it "should fail to parse the request" do
143
+ expect do
144
+ server . read_request
145
+ end . to raise_exception ( Protocol ::HTTP1 ::LineLengthError )
146
+ end
147
+ end
125
148
end
You can’t perform that action at this time.
0 commit comments