I am trying to make a small HTTP server in Ruby. Its just designed to learn how the material works, nothing special. So what I did was send the server an ajax request. The server is listening on port 2000, so the ajax request is also on port 2000.
The problem I am facing is that the ajax request is returned only with headers, the content is missing. I tried everything I could find, but it doesn't seem to work either ...
I attached the code for you to watch
require 'socket'
server = TCPServer.new(2000)
loop {
client = server.accept
headers = "HTTP/1.1 200 OK\r\nDate: Tue, 14 Dec 2010 10:48:45 GMT\r\nServer: Ruby\r\nContent-Type: text/html; charset=iso-8859-1\r\n\r\n"
client.puts headers
client.puts "<html>amit</html>"
client.close
}
The ajax request works when pointed to by a PHP script running on Apache. the only problem is when using this server.
Any help, as always, is greatly appreciated :)
Regards, Amit