Skip to content
⌘ NSIS Forum Archive

http + ftp download plug-in

545 posts

{_trueparuex^}#
There was bug in the content length / accept ranges check in my last file. So here's a new one.
janekschwarz#
I think there is a bug in inetc:😛ut. When I try to upload a file, the http header content-length is always 0. Here's an example:

======= Start =======
PUT / HTTP/1.1
Content-Type: octet-stream
Content-Length: 0
User-Agent: NSIS_Inetc (Mozilla)
Host: XXXXXXXX.de:8812
Connection: Keep-Alive
Cache-Control: no-cache

line1
line2
======= End =======

In the NSIS script I use this line:

inetc:😛ut "http://docstore.interchange.de:8812/" "$EXEDIR\testfile" /END

When I upload the file with curl (curl -T testfile http://XXXXXXXX.de:8812) everything works as expected:

======= Start =======
PUT /testfile HTTP/1.1
User-Agent: curl/7.16.3 (i686-pc-cygwin) libcurl/7.16.3 OpenSSL/0.9.8g zlib/1.2.3 libssh2/0.15-CVS
Host: XXXXXXXX.de:8812
Accept: */*
Content-Length: 16
Expect: 100-continue

line1
line2
======= End =======

On XXXXXXXX.de:8812 runs netcat (nc -l -p 8812) which does nothing more than capturing everything that comes in on port 8812. Inetc and curl connect directly to the server (no proxies).


Is this a know problem? Unfortunately, I don't have Visual Studio available, so I can't dive in the code myself. But I'd love to help debugging it on the server side if needed.
Takhir#
Thanks, janekschwarz. Bug was added in the Jan. 30, 2007 revision. Fixed now, please update your files.
janekschwarz#
Takhir, thanks again for the fix. It works.

Another question: Does http authentication work with inetc:😛ut? I tried something simple (http://user😛asswd@XXXXXXXX.de/puttest/put.php) and always get an 401 error back. Curl authenticates successfully.
Takhir#
Thanks, janekschwarz! I could reproduce this issue, probably this configuration was not tested earlier. Short googling gave me few similar questions, but no answers yet. Server accepts PUT request, receives file, but returns 401 in EndRequest() status header. Download from the same protected folder (.htaccess overridden) works correct. Any ideas?
janekschwarz#
I did an experiment. Authentication works if I set the Authorization header my self:

inetc:😛ut /HEADER "Authorization: Basic PXVzZXI6cGFzc3dk" "http://XXXXXXXX.de/puttest/put.php" "$EXEDIR\testfile" /END

Maybe the trick is to send the Authorization headers preemptively.
Takhir#
And thank you again, janekschwarz!
I tested patch (internal base64 login😛asswd encoding) and it worked fine. When (and if) sourceforge will work again I'll put new zip to server.
janekschwarz#
Hi, thank you for the fix.

I hate to admit it, but I found another problem: inetc:😛ut through an authenticating proxy does not work. It gives up right after receiving the 407 status code from the proxy and does not ask for proxy credentials (example.nsi contained in the zip file does, so it works in principle).

Any ideas?
Takhir#
Unicode

I attached unicode version on inetc plug-in to this post - worked correct during my (short) testing. Wiki version has the same TCHAR decoration, so the only difference with archive code is path to exdll.h. I'll convert project to VS 2005 with additional Unicode configurations and put to wiki later (after some tests, and I hope you will help me). Version with log prints (for debugging) is temporary available here http://ineum.narod****inetc.htm
Have fun 🙂
Afrow UK#
By the way there is a slight issue when using inetc on the install files page. If you haven't clicked the show details button, then everything is fine (inetc disables it, fine). If however, you do click the show details button before downloading, inetc shows over the log window without hiding it.

Be nice if this code could go in the plug-in but this is how to sort it in NSIS script:

!macro DownloadPre
FindWindow $R0 `#32770` `` $HWNDPARENT
GetDlgItem $R0 $R0 1016
System::Call user32::IsWindowVisible(iR0)i.R1
StrCmp $R1 0 +2
ShowWindow $R0 ${SW_HIDE}
!macroend
!define DownloadPre `!insertmacro DownloadPre`

!macro DownloadPost
StrCmp $R1 0 +2
ShowWindow $R0 ${SW_SHOW}
!macroend
!define DownloadPost `!insertmacro DownloadPost`

...

${DownloadPre}
inetc::get ...
${DownloadPost}
Just make sure you don't touch the $R0 and $R1 variables between DownloadPre and DownloadPost.

Stu
Takhir#
Thanks, Stu, I'll try to add this feature to next release. Is 1016 unique value for this page-control?
This morning I uploaded inetc version with (I hope) finally fixed PUT issue if proxy or HTTP server authorization required (many thanks to janekschwarz). Problem was in proxy/server auth request that came back after all data were already sent (and progress bar reached right border). New version for HTTP PUT first tests connection using OPTIONS request. The only remaining 'difficult' situation is PUT to HTTPS if proxy/server authorization data to be requested from user (in password/login dialog) because OPTIONS request to HTTPS failed in my tests.
Takhir#
Inetc restores original button style after transfer complited. May be nothing to 'show' in your sample? 😉
l0k1#
If i use Inetc plugin in .OnInit function, installer never gets focus when launched.
Ex :


!include "MUI2.nsh"
Name "test"
OutFile "Install.exe"
RequestExecutionLevel Admin

!InsertMacro MUI_PAGE_License $(license)
!InsertMacro MUI_PAGE_INSTFILES
Function .onInit
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

HTTP:
InetC::Get /SILENT "http://www.google.com" "$TEMP\bug.txt" /END
Pop $0
StrCmp $0 "OK" OK
ERR:
messagebox mb_ok "Error : $0"
OK:

FunctionEnd
Section
SectionEnd
Another problem with close button :

I have a script with AutoClose = True and InetC command in .OnInstSuccess function

If a user click on the button before the page desappears then the execution of the script jump to a random location (always the same though).

Any help ?
thx
Takhir#
1. You can find related discussion on page 5 of this thread.
2. Any plug-in require installer running, may not work when on the exit step, so it's not a good idea to run inetc in .OnInstSuccess.
Vytautas#
Is this a bug or am i doing something wrong?

I'm trying to download a file from https using authentication, the username dialog comes up fine and works as expected when wrong and right usernames are entered.

However is one clicks cancel on that dialog, inetc downloads the http error report and sets status to OK. Is there a way to detect if/when this happens?

Vytautas
Takhir#
This is a bug. InternetErrorDlg() returns ERROR_SUCCESS 0 on Cancel click (I hoped this to be ERROR_CANCELLED 1223 as MSDN declares). Thanks, Vytautas, I'll put updated to server version as soon as sourceforge will be up (with 2 other small changes).
Vytautas#
OK, Found another issue, when authentication is used even if the correct info is provided it displays canceled first time, then when retrying to authenticate it works OK.

here is the sample code used

downloadcrmsi:
StrCpy $CR_Install "$INSTDIR\CRRedist2005_x86.msi"
inetc::get /NOCANCEL "https://xyz.com/CRRedist2005_x86.msi" "$INSTDIR\CRRedist2005_x86.msi"
Pop $1
Dumpstate::debug
${If} $1 == "OK"
Goto installcr
${Else}
MessageBox MB_RETRYCANCEL "Download Failed!" IDRETRY downloadcrmsi
Abort "Crystal Reports Runtime 10.2 Download Failed"
${EndIf}
as can be seen even when correct login is specified i get a download failed box come up, when retry is pressed it connect straight away without asking for authentication
jiake#
If it better that if the plugins may support multilanguage. I'm Chinese, some plugins provide a header file to define multilanguge, some not. If all plugins support multilanguage, that is better.
Takhir#
Vytautas: thanks again! I hope this is fixed now..
jiake: yes, this would be better, but for now you can use /TRANSLATE option for /POPUP and NSISdl mode, /BANNER mode also has text parameters. Use LangString if you want to support few langs in your installer.
{_trueparuex^}#
Currently all 3xx errors are treated as redirection. You should add and exception for "304 not modified" status. Users may send "If-None-Match" or "If-Modified-Since" header to check if the file has changed on the server. 🙂
pengyou#
I use Inetc's /RESUME option to display a message when Inetc is unable to download a file. This is useful for users who are still using dial-up connections.

This /RESUME feature no longer works properly. If there is no connection to the internet the plugin now creates an empty file and does not return the "SendRequest Error". My installer then tries to use the empty file and fails because the file is zero bytes long.

The Inetc plugin dated 1 April 2008 is OK - if there is no connection to the internet it returns the "SendRequest Error".

The Inetc plugins dated 30 April, 4 May and 20 May 2008 do not return the "SendRequest Error" if the internet connection is down.
Takhir#
Not reproduces. I unplugged LAN cable (ethernet) and resume popup appears as expected. Exit status is SendRequestError.
Inetc::get /RESUME "" "http://kolobok/sfu_3.exe" "$EXEDIR\sfu.exe"
"$EXEDIR\u.jpg"
Pop $0
MessageBox MB_OK "Download Status: $0"
May 20 version.
pengyou#
The new Inetc plugin, dated 21 May 2008, fixes the problem so my installer now works properly.

Thank you for fixing this problem so quickly.
daisywheel#
/SILENT doesn't work

Hi,

Take a look at code below.

Name "test"
OutFile "test.exe"

;SilentInstall silent

!define UpdateConfigFile "update.ini"
!define UpdateURL "http://www.daisywheel.kiev.ua" ;


;---------------------------------------------------------------------------------
; Sections
;---------------------------------------------------------------------------------
Section

loop:

MessageBox MB_OK "hi!"

InetLoad::load /SILENT "${UpdateURL}/${UpdateConfigFile}" "$TEMP\${UpdateConfigFile}"
;InetLoad::load "${UpdateURL}/${UpdateConfigFile}" "$TEMP\${UpdateConfigFile}"
Pop $0
MessageBox MB_OK $0

StrCmp $0 "OK" 0 loop


SectionEnd
When I add /SILENT to InetLoad::load call I get not "OK" response but "connecting" and file is not loaded.

Is it a bug or do I misinterpret something?

tnx,
Roman
Takhir#
Please not /silent option description:
[/SILENT TEXT2DISPLAY]
SILENT
Key hides plug-in' output (both popup dialog and embedded progress bar). Sets TEXT2DISPLAY to 1006 control, if /silent "" - displays "InetLoad plug-in" default. Not required if 'SilentInstall silent' mode was defined in script (NSIS 2.03 option).