Excuse the tabs. I'm trying to download a file from remote to local and I keep getting one back that is exactly 310 bytes (regardless of what file I choose to download). I tried setting the timeout to 0, but this isn't working. What am I doing wrong? Thanks!
@downloadUrl = 'https://username:[email protected]' Net::HTTP.start(@downloadUrl) do |http| response = http.get('/file.ext') open('/Users/me/file.ext', "wb", :read_timeout=>0) do |file| file.write(response.body) end end EDIT: I don't want to use httpclient, I want to use standard net/http. I am almost there, but I keep getting initialize': getaddrinfo: nodename nor servname provided, or not known (SocketError) thrown at Net::HTTP.start(url.path). But when I remote "https", I get ECONNREFUSED. ...Getting closer?
url = URI.parse('https://api.net/file.ext') @request = Net::HTTP.start(url.path) @request.basic_auth 'username', 'password' sock = Net::HTTP.new(url.host, 443) sock.use_ssl = true sock.ssl_version='SSLv3' sock.start do |http| response = http.get(@request) open('/Users/me/file.ext', "wb", :read_timeout=>0) do |file| file.write(response.body) end end