Clifford said:
You make an HTTP proxy request, using an FTP URL.
An HTTP proxy request differs from a normal HTTP request
in that the GET line contains "
http://host.domain" at the
start of the URL string. Just replace the http with ftp,
add whatever username/password you need, and Squid will
do the FTP for you. The request line looks like:
GET ftp://user
[email protected]/pub/some_file HTTP/1.0
Okay, that's sounds easy, but I can't get it to work. Can you complete a
ftp-download example?
I have tried with the following (including variants of it), but can't
get it to work:
-----
#!/usr/bin/env ruby
require 'net/http'
Net::HTTP.start('ftp://anonymous:
[email protected]', 21) { |http|
response, data = http.get('/pub/gnu/mc/mc-4.5.55.tar.gz', nil)
File.open("mc.tgz", "wb") { |f|
f.write(data)
}
}
-----
I get the error trace:
-----
/pack/ruby-1.8.0/lib/ruby/1.8/net/protocol.rb:84:in `initialize':
getaddrinfo: Name or service not known (SocketError)
from /pack/ruby-1.8.0/lib/ruby/1.8/net/protocol.rb:84:in `new'
from /pack/ruby-1.8.0/lib/ruby/1.8/net/protocol.rb:84:in `connect'
from /pack/ruby-1.8.0/lib/ruby/1.8/net/protocol.rb:83:in `timeout'
from /pack/ruby-1.8.0/lib/ruby/1.8/timeout.rb:55:in `timeout'
from /pack/ruby-1.8.0/lib/ruby/1.8/net/protocol.rb:83:in `connect'
from /pack/ruby-1.8.0/lib/ruby/1.8/net/protocol.rb:65:in `initialize'
from /pack/ruby-1.8.0/lib/ruby/1.8/net/http.rb:422:in `open'
from /pack/ruby-1.8.0/lib/ruby/1.8/net/http.rb:422:in `do_start'
from /pack/ruby-1.8.0/lib/ruby/1.8/net/http.rb:409:in `start'
from /pack/ruby-1.8.0/lib/ruby/1.8/net/http.rb:324:in `start'
from ./ftpget.rb:4