Skip to content

Instantly share code, notes, and snippets.

@creadone
Last active May 1, 2021 01:43
Show Gist options
  • Save creadone/9b6c93a785e1a871f137738fc2287dc4 to your computer and use it in GitHub Desktop.
Save creadone/9b6c93a785e1a871f137738fc2287dc4 to your computer and use it in GitHub Desktop.
require 'uri'
require 'socket'
trap('SIGINT') { exit };
Socket.tcp_server_loop(3000) do |conn|
sleep 0.5
ts = "ts: #{Time.now.utc.to_i}\n"
puts ts
puts '-' * ts.size
puts conn.gets("\r\n\r\n")
conn.puts "HTTP/1.1 200 OK"
conn.puts "\r\n\r\n"
conn.close
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment