Skip to content
⌘ NSIS Forum Archive

http + ftp download plug-in

545 posts

Joost Verburg#
There really is a problem with Inetload FTP downloads and a recent version of the ProFTPD server. I also get 404 errors, even though the file exists. Try for example to download any file from ftp://ftp.lyx.org.
Takhir#edited
Thanks, Joost,
I could reproduce situation and found 'why' - see attached screenshot. The same answer in console:
ftp> literal SIZE apache-ant-1.7.0-bin.tar.bz2.md5
550 SIZE: Operation not permitted 
Server not 'eats' SIZE request and plug-in re-interprets 550 as 'file not found'. BTW 'ls -l' not gives extended info on this server as well. Finally I can make ftp working without file size, but IE displays this, so it is possible. Any Ideas?
Edited after short googling: BTW ProFTPD 550 on SIZE has a great history 🙂 http://www.google****search?hl=ru&q=...roblem+550&lr= And SIZE request fails even with FTP_TRANSFER_TYPE_BINARY for control connection.
Takhir#
OK, both inetc & inetload allow FTP download now even is server rejects SIZE request, but progress bar functionality will be unavailable while file size is unknown (the same happen with chunked http replies). And confusing '404' shold not appear any more.
imecstatic#
inetload crash on windows Vista

When I run setup on windows vista, sometimes it runs fine but sometimes it crashes.
Every time crash occurs while downloading. I am using InetLoad for downloading through following command:

InetLoad::load /TRANSLATE "Downloading %s" "Connecting ..." second minute hour s "%dkB (%d%%) of %dkB @ %d.%01dkB/s" "(%d %s%s remaining)" \
"192.168.1.204/xyz.exe" "$INSTDIR\xyz.exe" /END

Any help will be appreciated.
Takhir#
This happen sometimes in NSISdl mode you currently use. Happen in the part of code I took from NSISdl sources 🙂 The best way is to use inetc plug-in where this part was fully re-worked. inetc::get .... Or popup/banner mode of InetLoad. http://nsis.sourceforge.net/Inetc_plug-in
51819#
Section "Dummy Section" SecDummy

# parameters: URL local_file [reget_attempts [pause_sec]]
InetLoad::load "http://dl.zvuki****6306/mp3/1.mp3" "$EXEDIR\pavarotti.mp3" 3 10
Pop $0 # return value - exit code
MessageBox MB_OK "HTTP Download Status: $0"

SectionEnd
I don't like MessageBox show "HTTP Download Status: OK" when i completed Download
i like MessageBox show "HTTP Download Status: over"

how can i do it show over
empezar#
is there a way of cancelling the installer by pressing the [x] button on the inetc download window during .onInit?

what "termination code" does inetc provide when you press that [x] button, if any (again, during .onInit with /banner mode)? I've tried "Cancelled" and "Terminated", but I get seemingly random results, and they don't come right away, but after about 2 seconds, which seems a bit buggy to me.

this is the code I use:

GetTempFileName $NQUAKE_INI

Start:
inetc::get /NOUNLOAD /CAPTION "Initializing..." /BANNER "nQuake is initializing, please wait..." /TIMEOUT 5000 "${INSTALLER_URL}/nquake.ini" $NQUAKE_INI /END
Pop $0
${Unless} $0 == "OK"
${If} $0 == "Terminated"
MessageBox MB_OK|MB_ICONEXCLAMATION "Installation aborted."
Abort
${Else}
${Unless} $RETRIES > 0
MessageBox MB_YESNO|MB_ICONEXCLAMATION "Are you trying to install nQuake offline?" IDNO Online
StrCpy $OFFLINE 1
Goto InitEnd
${EndUnless}
Online:
${Unless} $RETRIES == 2
MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION "Could not download nquake.ini." IDCANCEL Cancel
IntOp $RETRIES $RETRIES + 1
Goto Start
${EndUnless}
MessageBox MB_OK|MB_ICONEXCLAMATION "Could not download nquake.ini. Please try again later."
Cancel:
Abort
${EndIf}
${EndUnless}
Takhir#
Plug-in should return "Cancelled" string if user pressed this button. Download thread exit may require some time if it waits for data from socket.
empezar#
okay.

seems to work, though sometimes i still get the "could not download" message instead of "installation aborted". i can live with that though.
empezar#
after further testing, I can say that I only get the "installation aborted" message when the download actually fails. I tried changing the download url to something that doesn't exist, and now everytime I press the [x] button, I get the wrong message ("are you trying to install nquake offline?").

so apparently, inetc only returns "Cancelled" if the download was successful AND cancelled?
DgtHorse#
URL Parts Error

My installer works fine on my machine but as soon as i run it on another machine it seems to download and at the end get a URL Parts error. i am using inetc get command with the /END prefixed and still getting it.

All i am downloading is the ASP.NET Ajax framework with the following command

inetc::get /caption "Downloading AJAX ASP.NET Framework 1.0" /canceltext "Cancel Download" "http://download.microsoft.com/download/5/4/6/5462bcbd-e738-45fa-84ca-fa02b0c4e1c2/ASPAJAXExtSetup.msi" "$INSTDIR\ajax.msi" /TIMEOUT 5000 /END

I do not know why it works on one and the other machine gets the URL Parts Error, anyone mind to shed some light on this? 🙂

TIA
DgtHorse#
aha! That did the trick!
Hmm, the fact that it worked on one machine and didn't in the other really did not strike me as writing the command erroneously :P
Joost Verburg#
InetLoad frequently crashes on Windows Vista while downloading from an FTP server. Did you test the Vista compatibility?
Takhir#
I tested InetLoad on Vista. Do you know any addition requirements for NSIS plug-ins on this OS? And please attach test script if you can reproduce crash. Might be good to compare situation with Inetc that not includes 'crashable' NSISdl code fragment. Thanks.
MrBlunden#
InetLoad is great!
I have a problem though: I'm using InetLoad to post installation status to a server.

When I call it before the first custom page (MUI) it makes the installer run in the background.

This is really bad cause when a user downloads my installation and the installer doesn't go to the front of the page, the user wouldn't know it's running.

Any way to solve this?
Takhir#
If new process (installer) creates any window during a short period of time, OS gives this window focus and sets it foreground. In your situation window appear too late (silent http request delay from .oninit function?). If you don't want to use InetLoad popup/banner, use one of NSIS banner plug-ins to catch foreground position. You can also try to use SetForegroundWindow call to move installer foreground, but this is not efficient in most OSes (InetLoad do this in silent mode for some reasons), see example in the attached script how to do this.
MrBlunden#
Takhir, thanks for you quick response.

Tried your code - Now after the post the installer flickers (windows xp) on the taskbar. No way to make the posting not steal focus?
Takhir#
The only good way I know is to create new window when process starts. Try to use InetLoad' own (/popup, /banner) or another banner.
Yes, on XP and later SetForeground causes flickering only.
empezar#
would it be possible to get some speed information on the /banner window?

i want to have customized download texts (i.e. not "downloading <filename>" but rather "downloading <file description"), but /banner makes the download speed text go away 🙁
Takhir#
Sorry, I am overloaded with urgent job, but for now you can create your version of plug-in with this output in the /banner window static field by copying code from /popup output timer function (C experience required).
{_trueparuex^}#
Small suggestion. Use the INTERNET_FLAG_NO_CACHE_WRITE flag in HttpOpenRequest() to disable writing in the IE cache. At the moment all downloaded files goes into to the cache as well.

I tried this my self and it seems to work so far. 🙂
Takhir#
Thanks! I'll add this to the next release.
BTW I prepared an dcompilled but not tested Unicode (TCHAR) version (because not sure that NSIS Unicode package will not damage current ANSI version), so if anybody want to test it - please send me private message (it's in Account on the page top).
{_trueparuex^}#
Originally posted by Takhir
Thanks! I'll add this to the next release.
There seems to be a problem with the resume ability while INTERNET_FLAG_NO_CACHE_WRITE is used. The MSDN page for InternetSetFilePointer() function state that...
...subsequent calls to InternetReadFile might block or return pending if the data is not available from the cache and the server does not support random access.
On my tests resume didnt work on any of the servers that I tried. Either those servers didn't support "random access" (whatever that means 🤪 ) or resume won't work at all while INTERNET_FLAG_NO_CACHE_WRITE is used. So I think it's better leave the cache writing on while resume is used.
{_trueparuex^}#
😳 From the InternetSetFilePointer() MSDN page "... This handle must not have been created with the INTERNET_FLAG_DONT_CACHE or INTERNET_FLAG_NO_CACHE_WRITE value set."

So using INTERNET_FLAG_NO_CACHE_WRITE breaks the resume for sure.

I realized that there's a small bug in the Inetc code. This statement is always true because InternetSetFilePointer() return type is DWORD.
if(!InternetSetFilePointer(hFile, cnt, NULL, FILE_BEGIN, 0))
You should use something like this.
if((int)InternetSetFilePointer(hFile, cnt, NULL, FILE_BEGIN, 0) == -1)
--

The IE cache writing still bothered me so I made a little research for alternative methods and I found this article.


I implemented the range request method described in there to Inetc code. It works without the cache, but probably isn't reliable as the InternetSetFilePointer() method.
Takhir#
Thank you very much {_trueparuex^}
I updated both inetc & inetload plug-ins. Also new feature in inetc: /question cancel_text (was requested here)
About no_cache_write using 'range request' - interesting idea for big files (like night movie downloads). Let's check reliability and if OK we'll add your code to inetc. Or you can write new multuthreaded super-fast downloader 😉
{_trueparuex^}#
Originally posted by Takhir
Thank you very much {_trueparuex^}
I updated both inetc & inetload plug-ins. Also new feature in inetc: /question cancel_text (was requested here)
About no_cache_write using 'range request' - interesting idea for big files (like night movie downloads). Let's check reliability and if OK we'll add your code to inetc. Or you can write new multuthreaded super-fast downloader 😉
No problem 🙂

...1500 megawatt Aperture Science heavy-duty super-threaded super loader. 😱 Seriously that's not a bad idea at all.


At least there shouldn't any difference on what servers the resume methods work...


But InternetSetFilePointer() definitely is more flexible and handles exceptions way better.