There are several mistakes:
1) you read TWICE on every sockread call, this results in half the data going to %s, and the other half to &temp
2) you don't distinguish between header data and user data, this results in some of the headers being written to your target file, thus making it invalid
3) echo -s banlist_download TOOK : $calc($ctime - %BL_DOWNLOAD_START_TIME) $+ secs is called multiple times during the process
try something like this:
alias banlist_download {
sockclose banlist_download
echo -s banlist_download Connecting to www.westor.ucoz.com ...
set %BL_DOWNLOAD_START_TIME $ctime
sockopen banlist_download www.westor.ucoz.com 80
}
ON *:SOCKOPEN:banlist_download: {
if ($sockerr > 0) { echo -s $sockname Error: Connection problem check your connection and try again later! | return }
echo -s $sockname Connected to westor.ucoz.com
sockwrite -n $sockname GET /remotes/banlist.rar HTTP/1.0
sockwrite -n $sockname User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10
sockwrite -n $sockname Host: westor.ucoz.com
sockwrite -n $sockname $crlf
}
ON *:SOCKREAD:banlist_download: {
if ($sockerr > 0) { echo -s $sockname Error: Connection problem check your connection and try again later! | return }
;; interpret as header data until we reach a null byte
if (!$sock($sockname).mark) {
var %s | sockread %s
if (content-length:* iswm %s) { echo -s $sockname $gettok(%s,2-,32) [SIZE] ! }
if (%s == $null) { sockmark $sockname 1 }
}
;; null byte found, everything that comes next, is data
else { sockread &temp | bwrite " $+ $mircdirdownloads\banlist.rar $+ " -1 -1 &temp }
}
on *:SOCKCLOSE:banlist_download: {
echo -s banlist_download TOOK : $calc($ctime - %BL_DOWNLOAD_START_TIME) $+ secs
}
also make sure you delete the .rar file each time before you start downloading, else it will just append to the end of the file! i.e. use something like
remove " $+ $mircdirdownloads\banlist.rar $+ "
at first line in your alias