I’m using the following code to download a file via HTTP in 1.6:
h = Net::HTTP.new(host, port)
resp = h.get2(path)
name = File.basename(path)
File.open(name, 'w') {|f| f.write(resp.body)}
Yet I’ve got reports that this doesn’t work in 1.7. Is there a way
that works in both versions?
Massimiliano
ts1
(ts)
2
Yet I've got reports that this doesn't work in 1.7. Is there a way
that works in both versions?
What is the error message
pigeon% cat b.rb
#!./ruby -v
require 'net/http'
host, port, path = 'www.ruby-lang.org', 80, '/en/index.html'
h = Net::HTTP.new(host, port)
resp = h.get2(path)
name = File.basename(path)
File.open(name, 'w') {|f| f.write(resp.body)}
pigeon%
pigeon% b.rb
ruby 1.7.3 (2002-10-24) [i686-linux]
pigeon%
pigeon% head -2 index.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
pigeon%
Guy Decoux