From: Eric Hodel Date: 2011-07-23T07:48:22+09:00 Subject: Re: open localhost url On Jul 22, 2011, at 2:46 PM, Hassan Schroeder wrote: > Not using Webrick -- that's a single-threaded server, so it can't > respond to your request until it finishes what it's doing -- sending > your request. Which obviously doesn't work too well. :-) WEBrick is not a single-threaded server. It can be configured as a single-threaded server but it is not by default: require 'webrick' require 'net/http' s = WEBrick::HTTPServer.new :Port => 8000 count = 0 s.mount_proc '/count' do |req, res| count += 1 res.body = count.to_s end s.mount_proc '/' do |req, res| Net::HTTP.start 'localhost', 8000 do |http| res.body = http.get('/count').body end end trap 'INT' do s.shutdown end trap 'TERM' do s.shutdown end s.start