Forum: Ruby question about http-access2

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
D1fc68a0247904549c74e71ab807d94f?d=identicon&s=25 Yin Chaoyi (Guest)
on 2006-02-15 11:35
(Received via mailing list)
Hello,

I am a ruby newbie. When I use the attached script, the file downloaded
over a slow link is always incomplete. I can successfully download a
much larger file over a fast link.

I use ethereal to capture the communication. It's the client which
initials the disconnection by first sending a FIN then followed by
several RSTs.

Any ideas? Thanks for helping!

------
#!/usr/bin/env ruby
require 'http-access2'

def fetch(url, filename)
   proxy = ENV['HTTP_PROXY']
   clnt = HTTPAccess2::Client.new(proxy)

   begin
     target = url
     clnt.reset(target)
     result = clnt.get(target)
   rescue SystemCallError
     return "Connection Error"
   end

   if result.contenttype != "application/pdf"
     return "can't get pdf!"
   else
     f = File.new(filename, File::CREAT|File::RDWR|File::TRUNC, 0644)
     f.puts result.content
     f.close
   end
   "Success"
end

puts fetch(ARGV.shift, ARGV.shift)
5befe95e6648daec3dd5728cd36602d0?d=identicon&s=25 Robert Klemme (Guest)
on 2006-02-15 14:18
(Received via mailing list)
Yin Chaoyi wrote:
> Any ideas? Thanks for helping!
Network (driver) timeout?

    robert
This topic is locked and can not be replied to.