This works on my system (Just brings back 128 bytes HTTP header). (Note
the extra '\n'...
That's one too many \n's now. There's one already at the end of Host:
www.google.com\n, so you only need one more to give the blank line.
But actually, to comply with RFCs, you need to send \r\n at the end of each
line:
require 'socket'
mySock = TCPSocket::new("www.google.com", 80)
mySock.write("GET / HTTP/1.1\r\n")
mySock.write("Host: www.google.com\r\n\r\n")
data = mySock.recv(128)
mySock.close
puts data
Quite a few webservers gracefully accept \n, but there are also plenty of
strict ones which don't - including Mongrel I believe.
HTH,
Brian.