on *:sockread:blah:{
if ($sockerr) return
while (!%headerend) {
sockread %header.data
ECHO -st -- %header.data -- %lookingfor.second.crlf --
if (!$sockbr) return
if (!%header.data) {
if (!%lookingfor.second.crlf) { set -s %lookingfor.second.crlf $true }
else { set -s %headerend $true | unset -s %lookingfor.second.crlf }
}
else { unset -s %lookingfor.second.crlf }
;^ [edit] added that line just now [edit]
}
:read
sockread -fn &a
if (!$sockbr) return
fwrite -b a &a
goto read
}
OK since I dont actually know what data comes before the start of the file, it makes it a bit hard, but someone said there were TWO consecutive $CRLF then the file data, so Im using that, if that isnt true then, well the above wont work.
Now what did i do?
It comes in and if %headerend isnt $true, then were in the header still, so just do a text read into variable, at this point i echo it to the status window for debugging sakes, since if it dont wokr u might like to show us what the header consists off. OK next exit if we didnt have nothing to read (i havent dont stuff all with sockets so im going to assume this value includes the $crlf 2 bytes if a blank line is read., next if the dataread turns out to be $null just the $crlf, then we go into the IF , if were not yet looking for the second crlf then set it so we are now, and if were already looking for the second $crlf then we just found it, so set that the header just ended, cleanup the second crlf flag, and the code exits the while loop into the binvar retrivial of the file.
[edit]
I just added a line to it that if the header data wasnt a $crlf then it resets the %lookingfor.second.crlf flag, as were not looking for JUST the second crlf, but the second consecutive crlf
[edit]
PS: remeber to reset the %headerend flag when initiating the send I would suggest also reseting the %lookingfor.second.crlf flag also, just to be sure.
(also take the -s out of the sets and the ECHO -st once its all a go go)
Hope i was able to help.