janko / down

Streaming downloads using Net::HTTP, http.rb or HTTPX
MIT License
1.03k stars 53 forks source link

wget backend raises EOFError #50

Closed abevoelker closed 4 years ago

abevoelker commented 4 years ago

Thanks for making an experimental wget wrapper; this is perfect for me because I need to handle an FTP server with flaky IPv6 support and I don't see any other Ruby libraries that let me force IPv4 easily!

When I try to download this file however it raises EOFError:

require "down/wget"
wget = Down::Wget.new("--inet4-only")
wget.open("ftp://lhcftp.nlm.nih.gov/Open-Access-Datasets/Pills/README")
# EOFError (end of file reached)

When I run the command it is generating manually in my CLI it works okay:

wget.send(:generate_command, "ftp://lhcftp.nlm.nih.gov/Open-Access-Datasets/Pills/README").join(" ")
# => "wget --no-verbose --save-headers -O - --inet4-only --user-agent Down/5.0.0 --max-redirect 2 --dns-timeout 30 --connect-timeout 30 --read-timeout 30 ftp://lhcftp.nlm.nih.gov/Open-Access-Datasets/Pills/README"

Here's my wget version FWIW

$ wget --version
GNU Wget 1.19.4 built on linux-gnu.

-cares +digest -gpgme +https +ipv6 +iri +large-file -metalink +nls 
+ntlm +opie +psl +ssl/openssl 

Wgetrc: 
    /etc/wgetrc (system)
Locale: 
    /usr/share/locale 
Compile: 
    gcc -DHAVE_CONFIG_H -DSYSTEM_WGETRC="/etc/wgetrc" 
    -DLOCALEDIR="/usr/share/locale" -I. -I../../src -I../lib 
    -I../../lib -Wdate-time -D_FORTIFY_SOURCE=2 -DHAVE_LIBSSL -DNDEBUG 
    -g -O2 -fdebug-prefix-map=/build/wget-Xb5Z7Y/wget-1.19.4=. 
    -fstack-protector-strong -Wformat -Werror=format-security 
    -DNO_SSLv2 -D_FILE_OFFSET_BITS=64 -g -Wall 
Link: 
    gcc -DHAVE_LIBSSL -DNDEBUG -g -O2 
    -fdebug-prefix-map=/build/wget-Xb5Z7Y/wget-1.19.4=. 
    -fstack-protector-strong -Wformat -Werror=format-security 
    -DNO_SSLv2 -D_FILE_OFFSET_BITS=64 -g -Wall -Wl,-Bsymbolic-functions 
    -Wl,-z,relro -Wl,-z,now -lpcre -luuid -lidn2 -lssl -lcrypto -lpsl 
    ftp-opie.o openssl.o http-ntlm.o ../lib/libgnu.a 

Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://www.gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Originally written by Hrvoje Niksic <hniksic@xemacs.org>.
Please send bug reports and questions to <bug-wget@gnu.org>

I will try to poke around and see if I can figure out what's going on but wanted to file an issue first.

abevoelker commented 4 years ago

Oh I see now - this probably won't work too well with FTP since it's reading HTTP Content-Length headers

abevoelker commented 4 years ago

I see now the library is focused on HTTP - I'll just port some of the basic wrapper logic to my app. Thanks!