Skip to content

Commit e4efb4a

Browse files
committed
Remove unnecessary gsub calls in test_httprequest.rb
1 parent 426e214 commit e4efb4a

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

Diff for: test/webrick/test_httprequest.rb

+11-12
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def test_invalid_content_length_header
8989
HTTP
9090
req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
9191
assert_raise(WEBrick::HTTPStatus::BadRequest){
92-
req.parse(StringIO.new(msg.gsub(/^ {8}/, "").gsub("\n", "\r\n")))
92+
req.parse(StringIO.new(msg))
9393
}
9494
end
9595
end
@@ -102,7 +102,7 @@ def test_bare_lf_request_line
102102
HTTP
103103
req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
104104
assert_raise(WEBrick::HTTPStatus::BadRequest){
105-
req.parse(StringIO.new(msg.gsub(/^ {6}/, "")))
105+
req.parse(StringIO.new(msg))
106106
}
107107
end
108108

@@ -114,7 +114,7 @@ def test_bare_lf_header
114114
HTTP
115115
req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
116116
assert_raise(WEBrick::HTTPStatus::BadRequest){
117-
req.parse(StringIO.new(msg.gsub(/^ {6}/, "")))
117+
req.parse(StringIO.new(msg))
118118
}
119119
end
120120

@@ -125,7 +125,7 @@ def test_header_vt_ff_whitespace
125125
\r
126126
HTTP
127127
req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
128-
req.parse(StringIO.new(msg.gsub(/^ {6}/, "")))
128+
req.parse(StringIO.new(msg))
129129
assert_equal("\x0b1\x0c", req["Foo"])
130130

131131
msg = <<~HTTP
@@ -135,7 +135,7 @@ def test_header_vt_ff_whitespace
135135
\r
136136
HTTP
137137
req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
138-
req.parse(StringIO.new(msg.gsub(/^ {6}/, "")))
138+
req.parse(StringIO.new(msg))
139139
assert_equal("\x0b1\x0c \x0b2\x0c", req["Foo"])
140140
end
141141

@@ -147,7 +147,7 @@ def test_bare_cr_request_line
147147
HTTP
148148
req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
149149
assert_raise(WEBrick::HTTPStatus::BadRequest){
150-
req.parse(StringIO.new(msg.gsub(/^ {6}/, "")))
150+
req.parse(StringIO.new(msg))
151151
}
152152
end
153153

@@ -159,7 +159,7 @@ def test_bare_cr_header
159159
HTTP
160160
req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
161161
assert_raise(WEBrick::HTTPStatus::BadRequest){
162-
req.parse(StringIO.new(msg.gsub(/^ {6}/, "")))
162+
req.parse(StringIO.new(msg))
163163
}
164164
end
165165

@@ -171,7 +171,7 @@ def test_invalid_request_lines
171171
HTTP
172172
req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
173173
assert_raise(WEBrick::HTTPStatus::BadRequest){
174-
req.parse(StringIO.new(msg.gsub(/^ {6}/, "")))
174+
req.parse(StringIO.new(msg))
175175
}
176176

177177
msg = <<~HTTP.gsub("\n", "\r\n")
@@ -181,7 +181,7 @@ def test_invalid_request_lines
181181
HTTP
182182
req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
183183
assert_raise(WEBrick::HTTPStatus::BadRequest){
184-
req.parse(StringIO.new(msg.gsub(/^ {6}/, "")))
184+
req.parse(StringIO.new(msg))
185185
}
186186

187187
msg = <<~HTTP.gsub("\n", "\r\n")
@@ -191,7 +191,7 @@ def test_invalid_request_lines
191191
HTTP
192192
req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
193193
assert_raise(WEBrick::HTTPStatus::BadRequest){
194-
req.parse(StringIO.new(msg.gsub(/^ {6}/, "")))
194+
req.parse(StringIO.new(msg))
195195
}
196196

197197
msg = <<~HTTP.gsub("\n", "\r\n")
@@ -201,7 +201,7 @@ def test_invalid_request_lines
201201
HTTP
202202
req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
203203
assert_raise(WEBrick::HTTPStatus::BadRequest){
204-
req.parse(StringIO.new(msg.gsub(/^ {6}/, "")))
204+
req.parse(StringIO.new(msg))
205205
}
206206
end
207207

@@ -427,7 +427,6 @@ def test_null_byte_in_header
427427
Evil: evil\x00\r
428428
\r
429429
HTTP
430-
msg.gsub!(/^ {6}/, "")
431430
req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
432431
assert_raise(WEBrick::HTTPStatus::BadRequest){ req.parse(StringIO.new(msg)) }
433432
end

0 commit comments

Comments
 (0)