Skip to content
⌘ NSIS Forum Archive

http + ftp download plug-in

545 posts

zenpoy#
1. regarding the winint.dll and https->http redirection in xp sp2, I found out this http://support.microsoft.com/kb/907301 issue, and applying the hotfix (which only replaces winint.dll and adds registry key) solves it! the bad news is that wininit.dll is a 'KnownDll' which means it always loaded from Windows\System32 and only OS can update it. I think the only way is to change the redirection to be like XP SP2 wants.

2. regarding the 'cancel' bug - looks good 🙂 The bug is not related to multiple downloads, I use only one download at a time, and I had this bug.
tperquin#
Hello Takhir,

First of thanks for the plugin. I however encountered a problem with the FTP PUT functionality of the plugin. It has to do when PUTing files that are in non-existing (on the FTP server) subdirectories.

The plugin determines if a FTP PUT upload failed due to a non existing subdirectory and tries to create the necessary subdirectories.

However the code that determines non-existing subdirectories relies on the FTP server's response. And I encountered a FTP server where the code in the plugin failed.

I attached two images with the different responses by different FTP servers on non-existing directory.

Code fix should be easy, around line 528 in inetc.cpp:

if(fput && _tcsstr(buf, _T("550")) != NULL)
{
Change to: (or what you prefer)

if(fput && (_tcsstr(buf, _T("550")) != NULL || _tcsstr(buf, _T("553")) != NULL))
{
I saw a few messages that also had problem with subdirectories and FTP PUT earlier in the thread. Those probably had to do with this as well.
Takhir#
Good job, tperquin, than you!
I uploaded new release http://nsis.sourceforge.net/File:Inetc.zip
CritterNYC#
It seems that inetc, even in a completely silent installer with no splash screen or other plugins, will still steal focus from another app when it is instantiated. Does anyone know of a fix for this?
Zinthose#
It looks like inetc::head is corrupting the stack.

    DetailPrint "Beer is placed on the stack.."
Push "BEER"

inetc::head "http://download.macromedia.com/pub/flashplayer/current/install_flash_player_ax_32bit.exe" "$TEMP\Temp.dat"
Pop $0
DetailPrint "Result of inetc::head = $0"

DetailPrint "Reach for Beer..."
Pop $0
${If} $0 == "BEER"
DetailPrint "Sip... ahh... sweet sweet beer!"
${Else}
DetailPrint "I'm sorry but inetc::head drank your beer. :'-("
${EndIf}
Please won't someone find my beer?
zenpoy#
Zinthose, try putting /END as the last argument to tell inetc where is the end of your argument list:

inetc::head "http://download.macromedia.com/pub/flashplayer/current/install_flash_player_ax_32bit.exe" "$TEMP\Temp.dat" /END
klopfdreh#
Details button and information text in instfiles page

Hello!

Since I wrote the last time into this thread the plugin is working like a charm, so thanks a lot first!

I have only two little feature request regarding the detail button and the information which are being displayed.

1. Is it possible not to grey the button out, but instead to make it pushable and print the downloading information into the textarea on each refresh?

Example:
<filename>: 14071kb (6%) of 234523kb @ 1543.0kb/s (2 seconds remaining)
<filename>: 32833kb (14%) of 234523kb @ 1543.0kb/s (2 seconds remaining)
<filename>: 53940kb (23%) of 234523kb @ 1543.0kb/s (2 seconds remaining)
.
.
.

2. Is there a way to show which file is downloading at the moment, because in my installer there is only the product name displayed on top of the installation bar?

Example:

Downloading: <filename>
[ || || || || || || || || || || || || || || || || || || || || ]

Thanks a lot!
dravster#
Odd Error with Inetc::get

Using the below simple test code at both my work (win7) and home (xp) hosts I get
the error "U" off the stack. I'm using NSIS 2.46 and the latest Inetc plugin from
http://nsis.sourceforge.net/Inetc_plug-in.



Name "InetClient GET Test"
OutFile "get.exe"

!AddPluginDir ./plugins

!include "MUI.nsh"
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install-colorful.ico"
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"

Section "Dummy Section" SecDummy

SetDetailsView hide
; single file, NSISdl-style embedded progress bar with specific cancel button text

inetc::get /canceltext "interrupt!" "http://drav.net/test.md5" "$EXEDIR\test.md5" /end
; NSISdl::download /TIMEOUT=30000 http://drav.net/test.md5 $TEMP\test.md5
Pop $1
MessageBox MB_OK "Download Status: $1"

SectionEnd

;--------------------------------
;Installer Functions

Function .onInit
FunctionEnd
The Error appears as so (and no file is downloaded).

Takhir#
test.md5 38 bytes, status OK. String may be trancated to first char only ('U') if you use Unicode plug-in version with multibyte installer.
dravster#
Re: Odd Error with Inetc::get

Yep that was it, drop in the "plugin/Inetc.dll" file (rather than unicode/Inetc.dll) and volia - It works 😁

Cheers for the quick response (as ever!) Takhir!

Regards

D.
klopfdreh#
Originally Posted by klopfdreh View Post
Hello!

Since I wrote the last time into this thread the plugin is working like a charm, so thanks a lot first!

I have only two little feature request regarding the detail button and the information which are being displayed.

1. Is it possible not to grey the button out, but instead to make it pushable and print the downloading information into the textarea on each refresh?

Example:
<filename>: 14071kb (6%) of 234523kb @ 1543.0kb/s (2 seconds remaining)
<filename>: 32833kb (14%) of 234523kb @ 1543.0kb/s (2 seconds remaining)
<filename>: 53940kb (23%) of 234523kb @ 1543.0kb/s (2 seconds remaining)
.
.
.

2. Is there a way to show which file is downloading at the moment, because in my installer there is only the product name displayed on top of the installation bar?

Example:

Downloading: <filename>
[ || || || || || || || || || || || || || || || || || || || || ]

Thanks a lot!
Hello again,

only wanted to say that I solved the "2." by settings the right caption, but point "1." would be really nice if it is possible. 😁
barabanger#
Originally Posted by CritterNYC View Post
It seems that inetc, even in a completely silent installer with no splash screen or other plugins, will still steal focus from another app when it is instantiated. Does anyone know of a fix for this?
I noticed same issue, at least when using inetc from another process. From what I discovered, to avoid this, WS_EX_NOACTIVATE style should be set in dialog template.
klopfdreh#
Hello everyone again,

I got some troubles with the inetc plugin and a low speed http server. After an undefined time the download aborts and a dialog show an error that the connection isn't available. If I press retry the dialog is shown again - so there is a loop which always show the error message and retry/abort. If I press abort the process is aborted as expected. The error is not within the time of 1800 seconds - it appears randomly.

I'm using the following call in our NSIS script:


inetc::get /NOCOOKIES /CONNECTTIMEOUT 1800 /RECEIVETIMEOUT 1800
/NOCANCEL /CAPTION "$(INETCHeader)${What}" /TRANSLATE
"$(INETC1)" "$(INETC2)" "$(INETC3)" "$(INETC4)" "$(INETC5)"
"$(INETC6)" "$(INETC7)" "$(INETC8)" /RESUME
"$(DownloadResumeWarning)" "$downloadURL${What}"
"$userhomeworkingdir\${What}" /END
Thanks a lot!
negativesir#edited
Originally Posted by CritterNYC View Post
It seems that inetc, even in a completely silent installer with no splash screen or other plugins, will still steal focus from another app when it is instantiated. Does anyone know of a fix for this?
Yes, this has to do with WM_INITDIALOG not returning false.

From MSDN:
The dialog box procedure should return TRUE to direct the system to set the keyboard focus to the control specified by wParam. Otherwise, it should return FALSE to prevent the system from setting the default keyboard focus.
Here is the fix for it, compiled in Visual C++ 6.0, tested on Windows 95.
negativesir#
Originally Posted by T.Slappy View Post
[OT] Thanks for the fix, but seriously you are using Visual C++ 6.0 and Win 95 ??? [/OT]
Yea. NSIS supports Windows 95 or higher. If I compile the source with anything higher than Visual C++ 6.0, the resulting DLL will not work on Windows 95. I have a Virtual PC Windows 95 image which makes it easy and I just had to downloaded Visual C++ 6.0. I compiled on Windows 7 and copied it over to the VM and tested the installer with the DLL.
T.Slappy#
Originally Posted by negativesir View Post
Yea. NSIS supports Windows 95 or higher. If I compile the source with anything higher than Visual C++ 6.0, the resulting DLL will not work on Windows 95. I have a Virtual PC Windows 95 image which makes it easy and I just had to downloaded Visual C++ 6.0. I compiled on Windows 7 and copied it over to the VM and tested the installer with the DLL.
[OT]
Thanks for explanation, nice job.

I assume nobody uses version below Windows 2000 and also Microsoft does not support such old versions any more.
[/OT]
negativesir#
Originally Posted by T.Slappy View Post
[OT]
Thanks for explanation, nice job.

I assume nobody uses version below Windows 2000 and also Microsoft does not support such old versions any more.
[/OT]
I don't doubt that. I know Microsoft doesn't support Windows 9X but NSIS does! Let me put it this way, I have a duty.. no a.. moral obligation.. to ensure that my patch does not break the minimum OS requirements.
T.Slappy#
Originally Posted by negativesir View Post
Let me put it this way, I have a duty.. no a.. moral obligation.. to ensure that my patch does not break the minimum OS requirements.
Like!!!
Afrow UK#
Where are you calling the plug-in from? To show download progress you probably need to use it in a Section (and without /silent).

Stu
zenpoy#
Can I resolve the filename from the request with inetc?

I have a url which I download a file from during install, this url is using redirection and the name of the file is based on some of the get parameters I use. Anyway, is there a way to use inetc to use/extract the filename from the last redirection in the redirection chains and use that as the filename? I have no problem do the change myself and try it, but I don't have to much experience with wininet api.

BTW - When I put the url in the browser (e.g. chrome) address bar it automatically uses the correct filename to save the file - this is the behaviour I would like to implement.

Thanks
maliktous#
Originally Posted by negativesir View Post
Yes, this has to do with WM_INITDIALOG not returning false.

Here is the fix for it, compiled in Visual C++ 6.0, tested on Windows 95.
Thank. You save my day.

Takhir, are you planning to include this fix into new version?
newuser10#
Hey guys,

Just a disclaimer, I'm still new to NSIS in general

The INETC plugin seems to work very well in general, although I'm having an issue which appears to be intermittent.. Basically i am attempting to retrieve a large number of files, approx 2 GB in size spread over 150 files and the transfer of some files are failing intermittently.

I am using the /resume switch and when the failure occurs it takes place somewhere in the middle of a file transfer, when I click on resume, I right away get the same popup coming up asking if i want to resume or cancel.

If i close up the installation package entirely, it will usually go through that file no issue but then fail on another. I'm not seeing any patterns as to specific files failing over and over again, it looks like its completely random.

I thought it might be network related so i ran wireshark to verify if the outbound httpd request goes through and it does.. Also, if i cancel that specific file the next few files go through without issue and since they are all retrieving from the same web server i don't believe its network related.

I'm not sure where to look to get this resolved, can i enable any additional logging?

I can post the script if necessary

Thanks in advance
T.Slappy#
Is there any safe way how to detect the source of the problem when downloading file fails (inetc::get) ?

Sometimes I am getting ERR_SENDREQUEST which is "SendRequest Error" but I cannot found the problem.

Here is code:
bool queryStatus(HINTERNET hFile)
{
    TCHAR buf[256] = _T("");
    DWORD rslt;
    if(HttpQueryInfo(hFile, HTTP_QUERY_STATUS_CODE,
        buf, &(rslt = sizeof(buf)), NULL))
    {
        buf[3] = 0;
        if(lstrcmp(buf, _T("0")) == 0 || *buf == 0) <<< The result code is zero (0) - but why???
            status = ERR_SENDREQUEST; 
tom_q#
Hi,

I'm trying to use inetc to download files. I allow users to cancel the download, and to try to download the file a second time. I use the following code:

Function OnDownloadPageClose
Push $0
;Download the file
inetc::get /BANNER "Download in progress." \
/CAPTION "Downloading..." \
"http://www.myuri.com/myfile.txt" \
"$DownloadDirectory\myfile.txt" \
/END
Pop $0
${If} $0 == "OK"
ExecWait "$DownloadDirectory\myfile.txt -d$\"$DownloadDirectory$\" -s"
Delete "$DownloadDirectory\myfile.txt"
${Else} ;an error occured
MessageBox MB_YESNO|MB_ICONEXCLAMATION \
"The file could not be downloaded. This may be due to a faulty \
Internet connection. Click 'Yes' to try again, or click 'No' to finish installation \
without downloading the optional files." \
IDNO exit
Delete "$DownloadDirectory\myfile.txt" ; !! THIS DOES NOT WORK
Pop $0
Abort ; do not go to the next installer page, so the user can try again.
${EndIf}
exit:
Pop $0
FunctionEnd
This does not work, most likely because when the download is interrupted by the user (closing the download pop-up) the half-downloaded-file cannot be deleted. It is also impossible to delete the file manually for as long as the installer is running ("Another program is using this file").

Edit: I get the same issue in other modes (besides banner mode) when clicking the cancel button. It seems like cancelled downloads are not properly handled -- the downloaded files are never closed. Then again it might just be that I have forgotten some essential operation.
aerDNA#
inetc automatically deletes the file on dl cancel; why it doesn't in your case, it's hard to say. Does the problem persist with some other file from a different server? Try using Unlocker to see if some 3rd party sw is hijacking the file. If you can't resolve the problem, a workaround can be to use GetTempFileName for the destination, then move the completed dl to target dir.