Robert Klemme wrote:
> 2009/7/8 Andy P. <andycootlapin / hotmail.fr>:
>>> You're looking for the class method in File:
>> Must I import other files ?
> Can you show specific code and errors?  As for Andrew, this worked for
> me out of the box:
> 
> 09:26:33 Temp$ irb19
> Ruby version 1.9.1
> irb(main):001:0> require 'open-uri'
> => true
> irb(main):002:0> open("http://www.google.com") {|src|
> irb(main):003:1*  open("test.htm","wb") {|dst|
> irb(main):004:2*      dst.write(src.read)
> irb(main):005:2>  }
> irb(main):006:1> }
> => 5337
> irb(main):007:0> exit
> 09:26:54 Temp$ wc test.htm
>    9  190 5337 test.htm
> 09:27:02 Temp$
> 
> Kind regards
> 
> robert


Sorry for the delay.

Yes, it works !


Now, I would want to download an image file using sockets.

require 'socket'
host = "www.google.fr"
port = 80
path = "/intl/fr_fr/images/logo.gif" #google logo
request = "GET #{path} GIF\r\n\r\n"
socket = TCPSocket.open(host, port)
socket.print(request)
response = socket.read
img = response.split("\r\n\r\n", 2)
puts img

It doesn't works : it returns :
"HTTP/1.1 400 Bad Request"

How to do ?
-- 
Posted via http://www.ruby-forum.com/.