From: Karl-Heinz Wild Date: 2007-04-09T03:18:30+09:00 Subject: Re: Trying to GET google with socket....problem On 08.04.2007, at 16:42, Brian Candler wrote: > On Sun, Apr 08, 2007 at 05:28:07AM +0900, Hey You wrote: >> Well I don't know why the socket can't connect to Google. Here is my >> source code: >> >> require 'socket' >> h = TCPSocket.new('www.google.ca',80) >> h.print "GET /index.html HTTP/1.0\n\n" >> a = h.read >> puts a >> >> I tried changing the HTTP to 1.1 but it still doesn't work. > > Two problems: > (1) Line terminator for HTTP is \r\n not \n > (2) You have not supplied a Host: header This means too send something like GET /index.html HTTP/1.1\r\n Host: www.google.ca\r\n \r\n \r\n Regards Karl-Heinz