Skip to content

Commit b8c4783

Browse files
authored
ci: fix ci - remove append_as_bytes logic, misc changes (#3861)
* ci: puma_socket.rb - remove `append_as_bytes` logic * ci: response.rb - misc update * ci: test_puma_server.rb - use `assert_includes` * ci: test_puma_server_hijack.rb - use `headers`
1 parent 44a3ac4 commit b8c4783

4 files changed

Lines changed: 9 additions & 20 deletions

File tree

test/helpers/test_puma/puma_socket.rb

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -239,22 +239,14 @@ def skt_closed_by_server(socket)
239239
end
240240
if no_body && part.end_with?(RESP_SPLIT)
241241
response.times = times
242-
if HAS_APPEND_AS_BYTES
243-
return response.append_as_bytes(part)
244-
else
245-
return response << part.b
246-
end
242+
return response << part
247243
end
248244

249245
unless content_length || chunked
250246
chunked ||= part.downcase.include? "\r\ntransfer-encoding: chunked\r\n"
251247
content_length = (t = part[/^Content-Length: (\d+)/i , 1]) ? t.to_i : nil
252248
end
253-
if HAS_APPEND_AS_BYTES
254-
response.append_as_bytes part
255-
else
256-
response << part.b
257-
end
249+
response << part
258250
hdrs, body = response.split RESP_SPLIT, 2
259251
unless body.nil?
260252
# below could be simplified, but allows for debugging...
@@ -278,12 +270,9 @@ def skt_closed_by_server(socket)
278270
to = time_end - Process.clock_gettime(Process::CLOCK_MONOTONIC)
279271
self.to_io.wait_writable to
280272
when nil
281-
if response.empty?
282-
raise EOFError
283-
else
284-
response.times = times
285-
return response
286-
end
273+
raise EOFError if response.empty?
274+
response.times = times
275+
return response
287276
end
288277
timeout = time_end - Process.clock_gettime(Process::CLOCK_MONOTONIC)
289278
if timeout <= 0

test/helpers/test_puma/response.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def headers_hash
2828
end
2929

3030
def status
31-
headers
31+
headers unless @status
3232
@status
3333
end
3434

test/test_puma_server.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1630,7 +1630,7 @@ def assert_does_not_allow_http_injection(app, opts = {})
16301630

16311631
response = send_http_read_response "HEAD / HTTP/1.0\r\n\r\n"
16321632

1633-
refute_match(/[\r\n]Cookie: hack[\r\n]/, response)
1633+
refute_includes response.headers, 'Cookie: hack'
16341634
end
16351635

16361636
# HTTP Injection Tests

test/test_puma_server_hijack.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def test_101_body
100100
echo_msg = "This should echo..."
101101
sock.syswrite echo_msg
102102

103-
assert_includes response, 'connection: Upgrade'
103+
assert_includes response.headers, 'connection: Upgrade'
104104
sock.wait_readable 0.2 # for TruffleRuby Errno::EAGAIN
105105
assert_equal echo_msg, sock.sysread(256)
106106
end
@@ -129,7 +129,7 @@ def test_101_header
129129
echo_msg = "This should echo..."
130130
sock.syswrite echo_msg
131131

132-
assert_includes response, 'connection: Upgrade'
132+
assert_includes response.headers, 'connection: Upgrade'
133133
sock.wait_readable 0.2 # for TruffleRuby Errno::EAGAIN
134134
assert_equal echo_msg, sock.sysread(256)
135135
end

0 commit comments

Comments
 (0)