[rubygems/rubygems] Align code styles with rubocop and others.

https://github.com/rubygems/rubygems/commit/c31a1592ee
This commit is contained in:
Hiroshi SHIBATA 2024-07-03 16:09:21 +09:00 коммит произвёл git
Родитель 7e69d74729
Коммит ba4495d75a
2 изменённых файлов: 10 добавлений и 16 удалений

Просмотреть файл

@ -86,7 +86,7 @@ gems:
end
def teardown
@fetcher.close_all if @fetcher
@fetcher&.close_all
if @normal_server
@normal_server.kill.join
@ -186,7 +186,7 @@ gems:
end
def start_server(data)
server = TCPServer.new('localhost', 0)
server = TCPServer.new("localhost", 0)
thread = Thread.new do
loop do
client = server.accept
@ -201,16 +201,12 @@ gems:
request_line = client.gets
headers = {}
while (line = client.gets) && line != "\r\n"
key, value = line.split(': ', 2)
key, value = line.split(": ", 2)
headers[key] = value.strip
end
if request_line.start_with?("GET /yaml")
response = if headers["X-Captain"]
headers["X-Captain"]
else
data
end
response = headers["X-Captain"] ? headers["X-Captain"] : data
client.print "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nContent-Length: #{response.size}\r\n\r\n#{response}"
elsif request_line.start_with?("HEAD /yaml") || request_line.start_with?("GET http://") && request_line.include?("/yaml")
client.print "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nContent-Length: #{data.size}\r\n\r\n#{data}"

Просмотреть файл

@ -36,7 +36,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
def teardown
if @ssl_server
# TODO lookup ssl_server status and close it properly
# TODO: lookup ssl_server status and close it properly
# @ssl_server.shutdown
@ssl_server = nil
end
@ -162,13 +162,11 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
loop do
ssl_client = ssl_server.accept
Thread.new(ssl_client) do |client|
begin
handle_request(client)
rescue OpenSSL::SSL::SSLError => e
warn "SSL error: #{e.message}"
ensure
client.close
end
handle_request(client)
rescue OpenSSL::SSL::SSLError => e
warn "SSL error: #{e.message}"
ensure
client.close
end
end
end