Skip to content
⌘ NSIS Forum Archive

http + ftp download plug-in

545 posts

Takhir#

http + ftp download plug-in

Attached plugin supports http and ftp downloads. Included script sample downloads 2 mp3 files (one for each protocol). I wrote it fast (from code pieces I had 🙂 ) and used the simplest InternetOpenUrl() way to do this, so functionality is limited (ftp restart may not work, WM_NOTIFY_OUTER_NEXT skipped, english only, ...). And dialog design is ugly 🙁 (any ideas?)
But finally http works good (many thanks to MS guys), I even tested download restart after disconnect (but this require more tests). Re-get defaults: disabled, pause 5 sec.
Takhir#
wording improved 🙂
Takhir#
Empty file size fields looks lonely 🙂 on ftp download, so I added ftp file size request. If ftp server not allows directory browsing (like dl.zvuki.ru does), InternetOpenUrl() fails and new connect (and time) required for file download, so I reworked this to common ftp session with single InternetConnect(). Script sample requests big (14 MB) file from MS ftp site (file size available), so better replace this with your own link.
Guest#
Can this plugin download silent and with process?

can can shellexecute it.

I am new in NSIS can you include a simple example?

Thanks...
Takhir#
This may be interesting - start download at the very beginning and run 2 processes, installation itself and file download (or I misunderstood something?).
It is possible to run dll as a process using rundll(32).dll, only new plug-in dll entry point required for this (short function). Programming side of problem is simple, but I'd like to understand first how to make working ftp reget using FtpCommand() call (size and restart commands). After this - may be.
If you want hide plug-in dialog in it's current state - comment ShowWindow() line in source code and rebuild project.
kichik#
What are the minimum requirements for this plug-in? It takes proxy settings from IE, right? I have been meaning to write a new NSISdl based on IE's downloading engine to solve all of those proxy problems. If you're already at it, how about you add an option to download more than one file in a row, I review the code, and we slap a NSISdl2 tag on it?
grahama#
yea 🙂
I am having a lot of problems with corporate networks using proxy settings
a new NSISdl would be fantastic
g
Takhir#
Originally posted by kichik
What are the minimum requirements for this plug-in? It takes proxy settings from IE, right?
I also had a full range of chunked HTTP + proxy problems in one of my apps when used socket based http client 🙁 . What is good for net learning, sometimes is bad for business 🙂 But few years ago Win95 compatibility requirement was taken off (in later Win versions IE and Inet API is always on place), and I could re-work it to Inet API.
Minimum requirements... HTTP without problems. I also thought about re-get functionality (for installers trying to download dotnetfx via dial-up) and about ftp, but it looks like both idias are not claimed by developers 🙂
OK, simple and stable http download without re-get, but more then one file. I thought about local path definition only (instead of every local file parameter), but this limits functionality with static server files only (not cgi/php), so parameters line is following:

InetLoad::load URL1 local_file1 [URL2 local_file2 [...]]

ftp works, but it not requests file size - InternetOpenUrl() functionality is limited.
Takhir#
to Kichik
I also thought a little about extended requirements and result attached, better ftp and simple (hidden) re-get. But more code - more bugs 🙂 You can use any version.
Takhir#
I fixed one bug in last (extended) version and improved download status displaying.
Takhir#
Good question. Plug-in works in my proxy tests, but this is 10% of success only 🙁 - independent test results required. I see non-zero downloads count, may be somebody (grahama) also can test plug-in 🙂 Another request - english spelling in the InetLoad.cpp (and may be dialog window).
Thanks.
Attached version functionality is almost the same as in the previous post, I only made an attempt to remember "coding rules" and re-formatted source text (for possible cvs commits 🙂.
grahama#
could add a Silent feature ?
something like:
inetLoad::load /SILENT "http://blah.com/blah.jpg" "$EXEDIR\blah.jpg"


will possibly get this thing tested today 🙂
g
grahama#
great news 🙂
initial tests from a client came back successful...
I'll go there myself to make sure later in the week...
but this is very good news as nothing was getting thru with nsisdl
g
Takhir#
Many thanks, grahama. I'll add this option (I tested right now - plug-in can take string from the stack and push it back if this is not /silent parameter 🙂 ), but let's wait a little for another replies.
Takhir#
New plug-in version with /SILENT support (optional).
Usage:
InetLoad::load [/SILENT] URL1 local_file1 [URL2 local_file2 [...]]

Returns "OK" string if download successful

Pop $0
StrCmp $0 "OK" dlok
MessageBox ...
Quit
dlok:
...
grahama#
thanks for the Silent Feature Takhir

is there a way I could pass along download info to the MUI interface like Nsisdl does ? very cool stuff 🙂
g
Takhir#
NSISdl uses "files" page for progress bar and status display. My variant uses it's own dialog window and may work even from .onInit function (without installer page) - I know situations when this is important. And I guess it is better to use more space for all these numbers and names displaying - url, local file, file size, done, transfer rate, remaining time, total time, percents. Another words I'd like to keep my dialog 🙂
I see 2 situations: 1) installer is visible and plug-in window appears as it is; 2) totally silent install and plug-in is also hidden (some logic may require in the plug-in call).
But it may be good to add something meaning above general prograss bar (1006 static, where installer shows file names) 🙂 , for example "InetLoad plug-in".
kichik#
In the latest CVS version, NSIS passes the silent flag which you can check.

I prefer the download dialog to show inside the NSIS dialog. It looks nicer.
Takhir#
Situation: program requires system SP to be installed ( >100 MB), this was found in .onInit function, but where to download SP? File copy page IMHO is not good place for this, might be better to do this after License page or even in .onInit function. But where to show progress bar if Installer’ dialog window not exists yet or have some other controls in this place (middle of the box). Or developers must create custom page for plug-in? I still guess that dialog box is better way (while dialog design is ugly ). Also: when user closes plug-in dialog window, plug-in’s main (dialog) thread tries to stop or terminate i/o thread – not bad when i/o hangs. When embedded to installer page this is not so obvious.
I added extra->exec_flags->silent support in some #ifdef’s to keep compatibility with current NSIS version (<=2.02). Code attached.
kichik#
No files should be downloaded in .onInit and anywhere else but the instfiles page. In my opnion, that's an annoying installer. I prefer installers to start "installing" only once I click install and verify all the parameters. But that can an option.

In NSISdl, another progress bar is created for the download status.

Clicking the Cancel button is more obvious than closing the download window.
Takhir#
I saw new progress bar created by NSISdl, but this is OK on instfiles page only, where this place is free. On the instfiles page - yes, this works fine.
When plug-in window is visible, installer page (if any) is unavailable, and (I hope) user will find how to close plug-in window. Or I can add there Cancel button (very easy in VS GUI).
The only place to start installation - yes, this is the best way, but life is very strange thing 🙂 NSIS gives a lot of user vars to plug-in (but not silent state), this looks as very specific option (back door), so why not to give opportunity to download file in advance?
grahama#
for myself, I use banners in the beginning to alert the user of a version check....I download an ini file and compare it to the values in the registry...because the inetLoad plugin is larger the banner...it looks a little strange...This is only cosmetic, but I thought it was worth bringing up🙂
having all the strings passed to the MUI [instead of the plugin dialog window] would be helpful in this particular situation...
grahama#
Ok, I went over to Univision's [the client] corporate office and inetload did not work with their proxy network 🙁 [nsisdl does not work either] My client launched the wrong installer...and told me it worked....
I am kind of at my wits end with this...Is there another installer product that works with proxy or is this something in the queue for NSIS...here is something odd that might be of note. My Apple powerbook[OS X] using Virtual PC [Win2k] gets thru their network on DHCP. Using the same installer app on THEIR pc does not get thru..... What would this point to ?
many thanks as I considering hard drugs at this point 😉
g
Jnuw#
I'm having a problem too with my work's proxy. When i try to use inetload to download a text file, the text file's contents are overwritten with the page can not be display message, and the following:

HTTP 407 Proxy Authentication Required - The ISA Server requires authorization to fulfill the request. Access to the Web Proxy service is denied. (12209)
Internet Security and Acceleration Server

Any ideas? Thanks all.
Takhir#
It’s not easy to debug program if you cannot touch the problem with your own hands J
I made one minor improvement for error 407 (proxy authorization), might be good to test it. But the main question is in explicit proxy authorization if IE registry parameters (already used) are not enough for connection. This require user_name and password. I see 2 simple ways to resolve the problem, silent InternetSetOption(INTERNET_OPTION_PROXY_PASSWORD + INTERNET_OPTION_PROXY_USERNAME) if these parameters presents in the plug-in call (something like “load /PASSWD=passwd …”) or popup dialog (InternetErrorDlg for example), where user can enter name and passwd for proxy auth (not works in the silent mode). Both variants may present in program, of course. First is good for corporate network distribution, second – for Inet downloads. If this is what you need – I’ll be in office in Monday and can make changes next week.
Also few words about http server authorization (error 401) – it is possible to define name and password in the URL, program extracts both parameters (if any. I did this for FTP if anonymous user is not accepted).
Jnuw#
Takhir, I found a minor issue. Your plugin is still working beautifully, and getting through my proxy with out any problems, so thanks again.

I'm using your plugin with nsis 2.03, no MUI, and with a silent install. I'm just using message boxes and banners. If I run the InetLoad::load command with the /SILENT switch, all future message boxes appear in the background behind other windows. If I remove the /SILENT switch from the InetLoad::load, which is fine, message boxes appear in front as they should. I tried using the BringToFront command, but that did not work. Just wanted to let you know about this, but all in all, your plugin is working great!