diff --git a/lib/sparoid.rb b/lib/sparoid.rb index a8d2271..f683a5d 100644 --- a/lib/sparoid.rb +++ b/lib/sparoid.rb @@ -152,7 +152,7 @@ def write_cache def public_ip(host = "checkip.amazonaws.com", port = 80) # rubocop:disable Metrics/MethodLength Socket.tcp(host, port, connect_timeout: 3) do |sock| sock.sync = true - sock.print "GET / HTTP/1.1\r\nHost: #{host}\r\nConnection: close\r\n\r\n" + sock.puts "GET / HTTP/1.1\r\nHost: #{host}\r\nConnection: close\r\n\r" status = sock.readline(chomp: true) raise(ResolvError, "#{host}:#{port} response: #{status}") unless status.start_with? "HTTP/1.1 200 " diff --git a/test/sparoid_test.rb b/test/sparoid_test.rb index 08d257e..46e25d7 100644 --- a/test/sparoid_test.rb +++ b/test/sparoid_test.rb @@ -72,9 +72,9 @@ def test_it_resolves_public_ip_only_once_per_instance # rubocop:disable Metrics/ assert_match "Host: ", client.readline(chomp: true) assert_equal "Connection: close", client.readline(chomp: true) - client.print "HTTP/1.1 200 OK\r\n" - client.print "Content-Length: #{client_ip.bytesize}\r\n" - client.print "\r\n" + client.puts "HTTP/1.1 200 OK\r" + client.puts "Content-Length: #{client_ip.bytesize}\r" + client.puts "\r" client.print client_ip client.close server.close