View Single Post
Old 5th November 2008, 19:02   #6
Animaether
Major Dude
 
Join Date: Jun 2001
Posts: 1,173
it's not so bad, hinmanj - here's a quick example script:

code:

!define DOWNLOAD_URL "http://www.google.com/intl/en_ALL/images/logo.gif"

; inetc.dll in the same folder as the source script.
; can remove this line if you've got it in NSIS\Plugins
!addplugindir "."

OutFile "content-length_test.exe"

Section
inetc::head /TIMEOUT 10000 ${DOWNLOAD_URL} "$EXEDIR\http.headers"
Pop $0
StrCmp $0 "OK" _ok
_error:
MessageBox MB_OK "Could not download."
goto _end
_ok:
StrCpy $R0 -1
FileOpen $0 "$EXEDIR\http.headers" "r"
_nextline:
ClearErrors
FileRead $0 $1
IfErrors _closeFile
StrCpy $2 $1 16
StrCmp $2 "Content-Length: " _found _nextline
_found:
StrCpy $R0 $1 "" 16
goto _closeFile
_closeFile:
FileClose $0
MessageBox MB_OK "File size: $R0 bytes"
_end:
SectionEnd

Animaether is offline   Reply With Quote