I am trying to implement a simple http server for debugging purposes.
The problem I am having is when I try to do something simple to print
out the request like:
	p session.readlines
My code hangs apparently waiting for more lines to be sent.

The code below shows how I currently print the request but I would
really prefer something that does not depend on timing.  Any
suggestions?

--------------------------------------------------------------
require 'socket'

server = TCPServer.new('localhost', 8090)
while (session = server.accept)

	body = "<html><body>you are not authorized to view this page.
#1</body></html>\r\n"

	headers = {}
	headers["Content-type"]= "text/html"
	headers["Connection"]= "close"
	headers["WWW-Authenticate"]= "NTLM"
	headers["Server"]= "Microsoft-IIS/5.1"
	headers["Content-length"]= "#{body.length}"

	session.puts "HTTP/1.1 401 Access Denied\r\n"
	headers.each {|key, value| session.puts "#{key}: #{value}\r\n"}
	session.puts "\r\n"
		
	session.puts body

	########Printing the request#########
	begin
		thread = Thread.new {
			session.each {|line| p line}
		}
		sleep .1
		thread.kill
	rescue Exception
	end
	#####################################
			
	session.close
end
--------------------------------------------------------------

Michael Hale - Software Developer
RoleModel Software Inc. - The XP Software Studio
www.rolemodelsoftware.com