=========================================================================================================================================

:			_HttpSC_CreateServer(ByRef $aBanList, $vIP, $iPort=80, $sServerName="Http SC", $fStart=True, $sLogFile="Http SC.log")
:		 HTTP 
:		_HttpSC_CreateServer($aBanList, $vIP, $iPort, $sServerName, $fStart, $sLogFile)
:
							$aBanList			=    ,        
							$vIP					= IP  (   IP ,  0  - -  ; 1  - 1 IP ),        
							$iPort				= [ : 80]    
							$sServerName	= [ : "Http SC"]  ,      
							$fStart				= [ : True]   True,          IP ;   False,      
							$sLogFile			= [ : "Http SC.log"]     .     (   ""),    .    .

:				   =      ;     = 0
@Error:				   = 0;     > 0
@Extended:		   = -     IP ;     = 0

:
	    ,  @Extended = 0,   $fStart = False,       ;
	 , @Extended    -  IP ,  ,  $fStart = True .
	   $vIP      _GelAllIp  "GelAllIp.au3".
	   _HttpSCError_ConvertError2Text  "Http SC Error.inc"    .
	  $fStart = False,      IP      _HttpSC_StartServer .

:
	#include "Http SC.inc"
	#include "Http SC Error.inc"
	
	Local $aServer, $aBanList
	$aServer = _HttpSC_CreateServer($aBanList, "127.0.0.1", 8080, "My server", 0, "C:\My Server.log")
		If @Error Then
		MsgBox(16, "CreateServer", _HttpSCError_ConvertError2Text(@Error, @Extended, True)); 
		Else
		MsgBox(64, "CreateServer", "  "); 
		EndIF
	
	_HttpSC_DeleteServer($aServer, $aBanList)
		If @Error Then MsgBox(16, "DeleteServer", _HttpSCError_ConvertError2Text(@Error, @Extended, True)); 
	Exit

=========================================================================================================================================

:			_HttpSC_StartServer(ByRef $aServer, ByRef $aBanList)
:		 HTTP  (   IP     )
:		_HttpSC_StartServer($aServer, $aBanList)
:
							$aServer		=    _HttpSC_CreateServer
							$aBanList		=    ,        

:				   = 1;     = 0
@Error:				   = 0;     > 0
@Extended:		   = -     IP ;     = 0

:
	    ,  @Extended = 0,       ;
	 , @Extended    -  IP .
	   _HttpSCError_ConvertError2Text  "Http SC Error.inc"    .
	   _HttpSC_CreateServer   $fStart = True,      .

:
	#include "Http SC.inc"
	#include "Http SC Error.inc"
	
	Local $aServer, $aBanList, $iDeletedSockets
	$aServer = _HttpSC_CreateServer($aBanList, "127.0.0.1", 8080, "My server", 0, "C:\My Server.log")
		If @Error Then MsgBox(16, "CreateServer", _HttpSCError_ConvertError2Text(@Error, @Extended, True)); 
	
	_HttpSC_StartServer($aServer, $aBanList)
		If @Error Then
		MsgBox(16, "StartServer", _HttpSCError_ConvertError2Text(@Error, @Extended, True)); 
		Else
		MsgBox(64, "StartServer", "  :   "&@Extended); 
		EndIF
	
	_HttpSC_DeleteServer($aServer, $aBanList)
		If @Error Then MsgBox(16, "DeleteServer", _HttpSCError_ConvertError2Text(@Error, @Extended, True)); 
	Exit

=========================================================================================================================================

:			_HttpSC_StopServer(ByRef $aServer, ByRef $aBanList)
:		 HTTP  (      IP ,      )
:		_HttpSC_StopServer($aServer, $aBanList)
:
							$aServer	=    _HttpSC_CreateServer
							$aBanList		=    ,        

:				   = -   ;     = 0
@Error:				   = 0;     > 0
@Extended:		   = -  ;     = 0

:
	 ,      -  IP .
	   _HttpSCError_ConvertError2Text  "Http SC Error.inc"    .

:
	#include "Http SC.inc"
	#include "Http SC Error.inc"
	
	Local $aServer, $aBanList, $iDeletedSockets
	$aServer = _HttpSC_CreateServer($aBanList, "127.0.0.1", 8080, "My server", 0, "C:\My Server.log")
		If @Error Then MsgBox(16, "CreateServer", _HttpSCError_ConvertError2Text(@Error, @Extended, True)); 
	
	_HttpSC_StartServer($aServer, $aBanList)
		If @Error Then MsgBox(16, "StartServer", _HttpSCError_ConvertError2Text(@Error, @Extended, True)); 
	
	$iDeletedSockets = _HttpSC_StopServer($aServer, $aBanList)
		If @Error Then
		MsgBox(16, "StopServer", _HttpSCError_ConvertError2Text(@Error, @Extended, True)); 
		Else
		MsgBox(64, "StopServer", "  .   "&$iDeletedSockets&";  : "&@Extended); 
		EndIF
	
	_HttpSC_DeleteServer($aServer, $aBanList)
		If @Error Then MsgBox(16, "DeleteServer", _HttpSCError_ConvertError2Text(@Error, @Extended, True)); 
	Exit

=========================================================================================================================================

:			_HttpSC_DeleteServer(ByRef $aServer, ByRef $aBanList)
:		 HTTP  (     _HttpSC_StopServer)
:		_HttpSC_DeleteServer($aServer, $aBanList)
:
							$aServer	=    _HttpSC_CreateServer
							$aBanList		=    ,        

:				   = -   ;     = 0
@Error:				   = 0;     > 0
@Extended:		   = -  ;     = 0

:
	 ,      -  IP .
	   _HttpSCError_ConvertError2Text  "Http SC Error.inc"    .

:
	#include "Http SC.inc"
	#include "Http SC Error.inc"
	
	Local $aServer, $aBanList, $iDeletedSockets
	$aServer = _HttpSC_CreateServer($aBanList, "127.0.0.1", 8080, "My server", 0, "C:\My Server.log")
		If @Error Then MsgBox(16, "CreateServer", _HttpSCError_ConvertError2Text(@Error, @Extended, True)); 

	_HttpSC_StartServer($aServer)
		If @Error Then MsgBox(16, "StartServer", _HttpSCError_ConvertError2Text(@Error, @Extended, True)); 
	
	$iDeletedSockets = _HttpSC_DeleteServer($aServer)
		If @Error Then
		MsgBox(16, "DeleteServer", _HttpSCError_ConvertError2Text(@Error, @Extended, True)); 
		Else
		MsgBox(64, "DeleteServer", "  .   "&$iDeletedSockets&";  : "&@Extended); 
		EndIF
	Exit

=========================================================================================================================================

:			_HttpSC_ConfigServer(ByRef $aServer, $iMaxConnectedUsers=20, $iMaxUserConnectsIn1Min=6, $iUserBanTimeSec=120)
:		   
:		_HttpSC_ConfigServer($aServer, $iMaxConnectedUsers, $iMaxUserConnectsIn1Min, $iUserBanTimeSec)
:
							$aServer								=    _HttpSC_CreateServer
							$iMaxConnectedUsers			= [ : 20]   ,       
							$iMaxUserConnectsIn1Min	= [ : 6]       ,   IP   
							$iUserBanTimeSec				= [ : 120]  ,          .  : > 60 ( 60)

:				   = 1;     = 0
@Error:				   = 0;     > 0
@Extended:		 0

:
	   _HttpSCError_ConvertError2Text  "Http SC Error.inc"    .

:
	#include "Http SC.inc"
	#include "Http SC Error.inc"
	
	Local $aServer, $aBanList
	$aServer = _HttpSC_CreateServer($aBanList, "127.0.0.1", 8080, "My server", 0, "C:\My Server.log")
		If @Error Then MsgBox(16, "CreateServer", _HttpSCError_ConvertError2Text(@Error, @Extended, True)); 

	_HttpSC_ConfigServer($aServer, 5, 3, 30)
		If @Error Then
		MsgBox(16, "ConfigServer", _HttpSCError_ConvertError2Text(@Error, @Extended, True)); 
		Else
		MsgBox(64, "ConfigServer", "  "); 
		EndIF
	
	_HttpSC_DeleteServer($aServer)
		If @Error Then MsgBox(16, "DeleteServer", _HttpSCError_ConvertError2Text(@Error, @Extended, True)); 
	Exit

=========================================================================================================================================

:			_HttpSC_ServerCheckIp(ByRef $aServer, $vIP)
:		, -    IP  (      IP )
:		_HttpSC_ServerCheckIp($aServer, $vIP)
:
							$aServer		=    _HttpSC_CreateServer
							$vIP				= IP  (   IP ,  0  - -  ; 1  - 1 IP ),        

:				   =      . ;     = 0
@Error:				   = 0;     > 0
@Extended:		 0

:
	   $vIP      _GelAllIp  "GelAllIp.au3".
	   _HttpSCError_ConvertError2Text  "Http SC Error.inc"    .

:
	#include "Http SC.inc"
	#include "Http SC Error.inc"
	#include "GelAllIp.au3"
	
	Local $aServer, $aBanList, $iSockets
	$aServer = _HttpSC_CreateServer($aBanList, "127.0.0.1", 8080, "My server", 0, "C:\My Server.log")
		If @Error Then MsgBox(16, "CreateServer", _HttpSCError_ConvertError2Text(@Error, @Extended, True)); 

	$iSockets = _HttpSC_ServerCheckIp($aServer, _GelAllIp(1))
		If @Error Then
		MsgBox(16, "ServerCheckIp", _HttpSCError_ConvertError2Text(@Error, @Extended, True)); 
		Else
		MsgBox(64, "ServerCheckIp", "     : "&$iSockets); 
		EndIF
	
	_HttpSC_DeleteServer($aServer)
		If @Error Then MsgBox(16, "DeleteServer", _HttpSCError_ConvertError2Text(@Error, @Extended, True)); 
	Exit

=========================================================================================================================================

:			_HttpSC_WhileList_Add(ByRef $aServer, $vIP)
:		    (  IP )  IP  ( 1 IP )
:		_HttpSC_WhileList_Add($aServer, $vIP)
:
							$aServer		=    _HttpSC_CreateServer
							$vIP				= IP  (   IP ,  0  - -  ; 1  - 1 IP ),      

:				   = 1;     = 0
@Error:				   = 0;     > 0
@Extended:		 0

:
	   $vIP   1D ,     0=-  ;   1=IP  1;   2=IP  2;    ....
	   _HttpSCError_ConvertError2Text  "Http SC Error.inc"    .
	        .

:
	#include "Http SC.inc"
	#include "Http SC Error.inc"
	
	Local $aServer, $aBanList, $iSockets
	$aServer = _HttpSC_CreateServer($aBanList, "127.0.0.1", 8080, "My server", 0, "C:\My Server.log")
		If @Error Then MsgBox(16, "CreateServer", _HttpSCError_ConvertError2Text(@Error, @Extended, True)); 

	$iSockets = _HttpSC_WhileList_Add($aServer, "192.168.0.2")
		If @Error Then
		MsgBox(16, "WhileList_Add", _HttpSCError_ConvertError2Text(@Error, @Extended, True)); 
		Else
		MsgBox(64, "WhileList_Add", " IP    !"); 
		EndIF
	
	_HttpSC_DeleteServer($aServer)
		If @Error Then MsgBox(16, "DeleteServer", _HttpSCError_ConvertError2Text(@Error, @Extended, True)); 
	Exit

=========================================================================================================================================

:			_HttpSC_WhileList_Del(ByRef $aServer, $vIP)
:		    (  IP )  IP  ( 1 IP )
:		_HttpSC_WhileList_Del($aServer, $vIP)
:
							$aServer		=    _HttpSC_CreateServer
							$vIP				= IP  (   IP ,  0  - -  ; 1  - 1 IP ),      

:				   = 1;     = 0
@Error:				   = 0;     > 0
@Extended:		 0

:
	   $vIP   1D ,     0=-  ;   1=IP  1;   2=IP  2;    ....
	   _HttpSCError_ConvertError2Text  "Http SC Error.inc"    .
	        .

:
	#include "Http SC.inc"
	#include "Http SC Error.inc"
	
	Local $aServer, $aBanList, $iSockets
	$aServer = _HttpSC_CreateServer($aBanList, "127.0.0.1", 8080, "My server", 0, "C:\My Server.log")
		If @Error Then MsgBox(16, "CreateServer", _HttpSCError_ConvertError2Text(@Error, @Extended, True)); 

	$iSockets = _HttpSC_WhileList_Del($aServer, "192.168.0.2")
		If @Error Then
		MsgBox(16, "WhileList_Del", _HttpSCError_ConvertError2Text(@Error, @Extended, True)); 
		Else
		MsgBox(64, "WhileList_Del", " IP    !"); 
		EndIF
	
	_HttpSC_DeleteServer($aServer)
		If @Error Then MsgBox(16, "DeleteServer", _HttpSCError_ConvertError2Text(@Error, @Extended, True)); 
	Exit

=========================================================================================================================================

:			_HttpSC_ReqestParse($sReqest, $sHeader)
:		        
:		_HttpSC_ReqestParse($sReqest, $sHeader)
:
							$sReqest		=    
							$sHeader		=  ,     , :  "Host" (.. $sHeader="Host")     

:				   =  ;     = 0
@Error:				   = 0;     > 0
@Extended:		 0

:
	     :  https://ru.wikipedia.org/wiki/%D0%A1%D0%BF%D0%B8%D1%81%D0%BE%D0%BA_%D0%B7%D0%B0%D0%B3%D0%BE%D0%BB%D0%BE%D0%B2%D0%BA%D0%BE%D0%B2_HTTP#.D0.94.D0.B0.D0.BD.D0.BD.D1.8B.D0.B5
	   _HttpSCError_ConvertError2Text  "Http SC Error.inc"    .

:
	#include "Http SC.inc"
	#include "Http SC Error.inc"
	
	Local $sReqest
	$sReqest = 'GET / HTTP/1.1'&@CRLF&'Host: astel064.16mb.com'&@CRLF&'User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:52.0) Gecko/20100101 Firefox/52.0'&@CRLF&'Connection: keep-alive'&@CRLF
	MsgBox(0,0, _HttpSC_ReqestParse($sReqest, "User-Agent") )

=========================================================================================================================================

:			_HttpSC_CreateAnswer(ByRef $aServer, $vSendData, $sHttpVersion="HTTP/1.1", $sAnswerCode="200 Ok",  $aLastModified="", $sContentType="text/html", $sAdditionalHeaders="", $sAuthenticateRealm="")
:		   (  )    
:		_HttpSC_CreateAnswer($aServer, $vSendData, $sHttpVersion, $sAnswerCode,  $aLastModified, $sContentType, $sAdditionalHeaders, $sAuthenticateRealm)
:
							$aServer			=    _HttpSC_CreateServer
							$vSendData		=  (  ),   
							$sHttpVersion	= [ : "HTTP/1.1"]    HTTP
							$sAnswerCode	= [ : "200 Ok"]    HTTP:
																200 Ok									=;
																400 Bad Request					= ;
																401 Unauthorized					= ;
																404 Not Found						=  ;
																500 Internal Server Error		=  
																
							$aLastModified	= [ : ""]         , :
																$aLastModified[0] = , (year, 4 )
																$aLastModified[1] =  (month,  01 - 12)
																$aLastModified[2] =  (day,  01 - 31)
																$aLastModified[3] =  (hour,  00 - 23)
																$aLastModified[4] =  (min,  00 - 59)
																$aLastModified[5] =  (sec,  00 - 59)
																    (""),      
																
							$sContentType	= [ : "text/html"] MIME  :
																application/json					= .json
																application/octet-stream	=     
																application/pdf					= .pdf
																audio/aac							= .aac
																audio/mpeg						= .mp3
																audio/ogg							= .ogg
																audio/x-ms-wma				= .wma
																audio/vnd.rn-realaudio		= .rm
																audio/vnd.wave					= .wav
																audio/webm						= .webm
																image/gif							= .gif
																image/jpeg						= .jpg;  .jfif;  .jpe;  .jpeg
																image/png							= .png
																image/tiff							= .tif
																image/vnd.microsoft.icon	= .ico
																image/vnd.wap.wbmp		= .wbmp
																image/webp						= .webp
																image/bmp						= .bmp;  .dib;  .rle
																text/css							= .css
																text/csv							= .csv
																text/html							= .html;  .htm;  .xhtml;  .xht
																text/javascript					= .js
																text/plain							= .txt
																text/xml							= .xml
																video/mpeg						= .mpg;  .mpeg;  .mp1;  .mp2;  .m1v;  .mpv;  .m1a;  .m2a;  .mpa
																video/mp4							= .mp4
																video/ogg							= .ogv
																video/webm						= .webm
																video/x-ms-wmv				= .wmv
																video/x-flv							= .flv
																video/3gpp						= .3gp
																
							$sAdditionalHeaders = [ : ""]  , :
																Date: Wed, 14 Jun 2017 09:37:02 GMT
																Last-Modified: Wed, 14 Jun 2017 08:51:50 GMT
																
																      
							$sAuthenticateRealm = [ : ""]      ,  $sAnswerCode="401 Unauthorized"     ,   


:				   =  ;     = 0
@Error:				   = 0;     > 0
@Extended:		 0

:
	      :  https://ru.wikipedia.org/wiki/%D0%A1%D0%BF%D0%B8%D1%81%D0%BE%D0%BA_%D0%BA%D0%BE%D0%B4%D0%BE%D0%B2_%D1%81%D0%BE%D1%81%D1%82%D0%BE%D1%8F%D0%BD%D0%B8%D1%8F_HTTP#.D0.9E.D0.B1.D0.B7.D0.BE.D1.80.D0.BD.D1.8B.D0.B9_.D1.81.D0.BF.D0.B8.D1.81.D0.BE.D0.BA
	  MIME    :  https://ru.wikipedia.org/wiki/%D0%A1%D0%BF%D0%B8%D1%81%D0%BE%D0%BA_MIME-%D1%82%D0%B8%D0%BF%D0%BE%D0%B2
	   $aLastModified      AutoIt (     ) "FileGetTime"
	   $sContentType     "_HttpSC_FileGetMimeType"
	   _HttpSCError_ConvertError2Text  "Http SC Error.inc"    .

=========================================================================================================================================

:			_HttpSC_FileGetMimeType($sFile)
:		 MIME  ,     
:		_HttpSC_FileGetMimeType($sFile)
:
							$sFile		=   (    )

:				   = MIME  
@Error:				 0
@Extended:		 0

:
	       "$sContentType"   "_HttpSC_CreateAnswer"
	   _HttpSCError_ConvertError2Text  "Http SC Error.inc"    .

:
	#include "Http SC.inc"
	MsgBox(0, "MIME .txt", _HttpSC_FileGetMimeType("File.txt"))
	MsgBox(0, "MIME .au3", _HttpSC_FileGetMimeType("C:\File.au3"))


=========================================================================================================================================

:			_HttpSC_ServerHandler(ByRef $aServer, ByRef $aBanList, $sGetFileFunc, $sPostFunc, $sOtherFunc, $sUserBanFunc="")
:		  :  ,  ,   
:		_HttpSC_ServerHandler($aServer, $aBanList, $sGetFileFunc, $sPostFunc, $sOtherFunc, $sUserBanFunc="")
:
							$aServer				=    _HttpSC_CreateServer
							$aBanList				=    ,        
							$sGetFileFunc		=          ( GET)
							$sPostFunc			=          ( POST)
							$sOtherFunc			=    ,      GET  POST 
							$sUserBanFunc	= [ : "" ( )]    ,     -       

:				   = 1;     = 0
@Error:				   = 0;     > 0
@Extended:		 0

:
	     $sGetFileFunc, $sPostFunc, $sOtherFunc  $sUserBanFunc   ( " ")
	   _HttpSCError_ConvertError2Text  "Http SC Error.inc"    .

:
	#include "Http SC.inc"
	#include "Http SC Error.inc"
	
	Global $aServer, $aBanList, $vSendData

	$aServer = _HttpSC_CreateServer($aBanList, "127.0.0.1", 8080, "My server", 0, @ScriptDir&"\My Server.log")
		If @Error Then Exit MsgBox(16, "CreateServer", _HttpSCError_ConvertError2Text(@Error, @Extended, True)); 

	_HttpSC_ConfigServer($aServer, 20, 15, 60)
		If @Error Then
		MsgBox(16, "ConfigServer", _HttpSCError_ConvertError2Text(@Error, @Extended, True)); 
		_HttpSC_DeleteServer($aServer)
		Exit 2
		EndIF
	
	_HttpSC_StartServer($aServer, $aBanList)
		If @Error Then
		MsgBox(16, "StartServer", _HttpSCError_ConvertError2Text(@Error, @Extended, True)); 
		_HttpSC_DeleteServer($aServer, $aBanList)
		Exit 3
		EndIF

	MsgBox(0,"StartServer"," . IP : 127.0.0.1;  : 8080.", 5)
	Global $fWhile = 1
	HotKeySet("{Esc}", "_Exit")
	
	While $fWhile
		_HttpSC_ServerHandler($aServer, $aBanList, "_GetServerFile", "_Post", "_OtherReqest", "")
		Sleep(250)
	Wend
	
	HotKeySet("{Esc}")

	_HttpSC_DeleteServer($aServer, $aBanList)
		If @Error Then MsgBox(16, "DeleteServer", _HttpSCError_ConvertError2Text(@Error, @Extended, True)); 
	Exit
	
	
	Func _GetServerFile($sUrl, $hUserSocket, $sUserIp, $sHttpVer, $Reqest)
		If $sUrl = "/" Then
		$vSendData = '<head>'&@CRLF
		$vSendData &= '<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">'&@CRLF
		$vSendData &= '<title>HttpSC</title>'&@CRLF
		$vSendData &= '</head>'&@CRLF
		$vSendData &= '<p align="center"><font size="5"><b>HttpSC</b></font></p>'&@CRLF
		$vSendData &= '<p align="left"><font size="3">: </font></p>'&@CRLF
		$vSendData &= '<p align="left"><font size="3">: '&@MDAY&"/"&@MON&"/"&@YEAR&'</font></p>'&@CRLF
		$vSendData &= '<p align="left"><font size="3">: '&@HOUR&":"&@MIN&":"&@SEC&'</font></p>'&@CRLF
		Return _HttpSC_CreateAnswer($aServer, $vSendData, "HTTP/1.1", "200 Ok",  _HttpSC_ConvertLastModifiedTime(@YEAR&"/"&@MON&"/"&@MDAY&' '&@HOUR&":"&@MIN&":"&@SEC), "text/html", "")
		Else
		$vSendData = '<head>'&@CRLF
		$vSendData &= '<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">'&@CRLF
		$vSendData &= '<title>HttpSC</title>'&@CRLF
		$vSendData &= '</head>'&@CRLF
		$vSendData &= '<p align="center"><font size="5"><b>HttpSC</b></font></p>'&@CRLF
		$vSendData &= '<p align="left"><font size="3">:  404</font></p>'&@CRLF
		$vSendData &= '<p align="left"><font size="3">: '&@MDAY&"/"&@MON&"/"&@YEAR&'</font></p>'&@CRLF
		$vSendData &= '<p align="left"><font size="3">: '&@HOUR&":"&@MIN&":"&@SEC&'</font></p>'&@CRLF
		Return _HttpSC_CreateAnswer($aServer, $vSendData, "HTTP/1.1", "404 Not Found",  "", "text/html", "")
		EndIF
	EndFunc

	Func _OtherReqest($hUserSocket, $sUserIp, $Reqest)
	Return ""
	EndFunc
	
	Func _Post($sUrl, $hUserSocket, $sUserIp, $sHttpVer, $Reqest)
		$vSendData = '<head>'&@CRLF
		$vSendData &= '<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">'&@CRLF
		$vSendData &= '<title>HttpSC</title>'&@CRLF
		$vSendData &= '</head>'&@CRLF
		$vSendData &= '<p align="center"><font size="5"><b>HttpSC</b></font></p>'&@CRLF
		$vSendData &= '<p align="left"><font size="3"> (POST): 200 </font></p>'&@CRLF
		$vSendData &= '<p align="left"><font size="3">: '&@MDAY&"/"&@MON&"/"&@YEAR&'</font></p>'&@CRLF
		$vSendData &= '<p align="left"><font size="3">: '&@HOUR&":"&@MIN&":"&@SEC&'</font></p>'&@CRLF
		$vSendData &= '<p align="left"><font size="3">POST  : </br>'&_HttpSC_PostReqestGetData($Reqest)&'</font></p>'&@CRLF
		$vSendData = _HttpSC_CreateAnswer($aServer, $vSendData, "HTTP/1.1", "200 OK",  "", "text/html", "")
		Return $vSendData
	EndFunc
	
	Func _Exit()
	$fWhile = 0
	EndFunc

=========================================================================================================================================

:			_HttpSC_ServerOptimization(ByRef $aServer, $fForced=0)
:		      
:		_HttpSC_ServerOptimization($aServer, $fForced)
:
							$aServer		=    _HttpSC_CreateServer
							$fForced		= [ : 0]   1,     , ,       ,   

:				   =   ;     = 0
@Error:				   = 0;     > 0
@Extended:		 0

:
	 ,   ,  "$aServer" (   "_HttpSC_CreateServer")     ,   ,   ,   .
	  .       ,   ,      .  "$fForced = 0",          
	    ,    1/3   .  "$fForced = 1",        ,    .     1   10   .
	   _HttpSCError_ConvertError2Text  "Http SC Error.inc"    .

:
	#include "Http SC.inc"
	#include "Http SC Error.inc"
	
	Global $aServer, $aBanList, $vSendData, $hOptimizationTimer

	$aServer = _HttpSC_CreateServer($aBanList, "127.0.0.1", 8080, "My server", 0, @ScriptDir&"\My Server.log")
		If @Error Then Exit MsgBox(16, "CreateServer", _HttpSCError_ConvertError2Text(@Error, @Extended, True)); 

	_HttpSC_StartServer($aServer, $aBanList)
		If @Error Then
		MsgBox(16, "StartServer", _HttpSCError_ConvertError2Text(@Error, @Extended, True)); 
		_HttpSC_DeleteServer($aServer, $aBanList)
		Exit 3
		EndIF

	MsgBox(0,"StartServer"," . IP : 127.0.0.1;  : 8080.", 5)
	Global $fWhile = 1
	HotKeySet("{Esc}", "_Exit")
	$hOptimizationTimer = TimerInit()
	
	While $fWhile
		_HttpSC_ServerHandler($aServer, $aBanList, "_GetServerFile", "_Post", "_OtherReqest", "")
		Sleep(250)
		If TimerDiff($hOptimizationTimer) >= 10*60*1000 Then;			10*60*1000 = 10 . * 60 . * 1000 .
			_HttpSC_ServerOptimization($aServer, 1);			 
			$hOptimizationTimer = TimerInit();			  
		EndIF
	Wend
	
	HotKeySet("{Esc}")

	_HttpSC_DeleteServer($aServer, $aBanList)
		If @Error Then MsgBox(16, "DeleteServer", _HttpSCError_ConvertError2Text(@Error, @Extended, True)); 
	Exit
	
	
	Func _GetServerFile($sUrl, $hUserSocket, $sUserIp, $sHttpVer, $Reqest)
		If $sUrl = "/" Then
		$vSendData = '<head>'&@CRLF
		$vSendData &= '<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">'&@CRLF
		$vSendData &= '<title>HttpSC</title>'&@CRLF
		$vSendData &= '</head>'&@CRLF
		$vSendData &= '<p align="center"><font size="5"><b>HttpSC</b></font></p>'&@CRLF
		$vSendData &= '<p align="left"><font size="3">: </font></p>'&@CRLF
		$vSendData &= '<p align="left"><font size="3">: '&@MDAY&"/"&@MON&"/"&@YEAR&'</font></p>'&@CRLF
		$vSendData &= '<p align="left"><font size="3">: '&@HOUR&":"&@MIN&":"&@SEC&'</font></p>'&@CRLF
		Return _HttpSC_CreateAnswer($aServer, $vSendData, "HTTP/1.1", "200 Ok",  _HttpSC_ConvertLastModifiedTime(@YEAR&"/"&@MON&"/"&@MDAY&' '&@HOUR&":"&@MIN&":"&@SEC), "text/html", "")
		Else
		$vSendData = '<head>'&@CRLF
		$vSendData &= '<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">'&@CRLF
		$vSendData &= '<title>HttpSC</title>'&@CRLF
		$vSendData &= '</head>'&@CRLF
		$vSendData &= '<p align="center"><font size="5"><b>HttpSC</b></font></p>'&@CRLF
		$vSendData &= '<p align="left"><font size="3">:  404</font></p>'&@CRLF
		$vSendData &= '<p align="left"><font size="3">: '&@MDAY&"/"&@MON&"/"&@YEAR&'</font></p>'&@CRLF
		$vSendData &= '<p align="left"><font size="3">: '&@HOUR&":"&@MIN&":"&@SEC&'</font></p>'&@CRLF
		Return _HttpSC_CreateAnswer($aServer, $vSendData, "HTTP/1.1", "404 Not Found",  "", "text/html", "")
		EndIF
	EndFunc
	
	Func _Post($sUrl, $hUserSocket, $sUserIp, $sHttpVer, $Reqest)
		$vSendData = '<head>'&@CRLF
		$vSendData &= '<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">'&@CRLF
		$vSendData &= '<title>HttpSC</title>'&@CRLF
		$vSendData &= '</head>'&@CRLF
		$vSendData &= '<p align="center"><font size="5"><b>HttpSC</b></font></p>'&@CRLF
		$vSendData &= '<p align="left"><font size="3"> (POST): 200 </font></p>'&@CRLF
		$vSendData &= '<p align="left"><font size="3">: '&@MDAY&"/"&@MON&"/"&@YEAR&'</font></p>'&@CRLF
		$vSendData &= '<p align="left"><font size="3">: '&@HOUR&":"&@MIN&":"&@SEC&'</font></p>'&@CRLF
		$vSendData &= '<p align="left"><font size="3">POST  : </br>'&_HttpSC_PostReqestGetData($Reqest)&'</font></p>'&@CRLF
		$vSendData = _HttpSC_CreateAnswer($aServer, $vSendData, "HTTP/1.1", "200 OK",  "", "text/html", "")
		Return $vSendData
	EndFunc

	Func _OtherReqest($hUserSocket, $sUserIp, $Reqest)
	Return ""
	EndFunc
	
	Func _Exit()
	$fWhile = 0
	EndFunc


=========================================================================================================================================

:			_HttpSC_ServerGet_ConnUsers(ByRef $aServer)
:		    IP     
:		_HttpSC_ServerGet_ConnUsers($aServer)
:
							$aServer		=    _HttpSC_CreateServer

:				  $aData, :
							$aData[0][0] =    ( = -  )
							$aData[1][0] =   .   
							$aData[1][1] = IP   .   
@Error:				   = 0;    :
							6		=    (  )
							11		=    (  )
@Extended:		 =   

:
	   _HttpSCError_ConvertError2Text  "Http SC Error.inc"    .

=========================================================================================================================================

:			_HttpSC_ServerGet_ServerSockets(ByRef $aServer)
:		   IP    ,    
:		_HttpSC_ServerGet_ServerSockets($aServer)
:
							$aServer		=    _HttpSC_CreateServer

:				  $aData, :
							$aData[0][0] =     . . 
							$aData[1][0] = IP ,      
							$aData[1][1] =   
@Error:				   = 0;    :
							6		=    (  )
							11		=    (  )
@Extended:		 =   

:
	   _HttpSCError_ConvertError2Text  "Http SC Error.inc"    .

=========================================================================================================================================

:			_HttpSC_ServerGet_BannedUsersIp(ByRef $aServer)
:		   IP   
:		_HttpSC_ServerGet_BannedUsersIp($aServer)
:
							$aServer		=    _HttpSC_CreateServer

:				  $aData, :
							$aData[0] =   
							$aData[1] = IP    
@Error:				   = 0;    :
							6		=    (  )
							11		=    (  )
@Extended:		 =   

:
	   _HttpSCError_ConvertError2Text  "Http SC Error.inc"    .
	     ,      IP    .

=========================================================================================================================================

:			_HttpSC_PostReqestGetData($sReqest, $fConvert=0)
:		   POST    
:		_HttpSC_PostReqestGetData($sReqest, $fConvert)
:
							$sReqest		=    POST 
							$fConvert		= [ : 0]   1,      ([0][0]=- ; [1][0]= ; [1][1]= ).   0,         

:				   =  ;     = 0
@Error:				   = 0;     > 0
@Extended:		 0

:
	     :  https://ru.wikipedia.org/wiki/%D0%A1%D0%BF%D0%B8%D1%81%D0%BE%D0%BA_%D0%B7%D0%B0%D0%B3%D0%BE%D0%BB%D0%BE%D0%B2%D0%BA%D0%BE%D0%B2_HTTP#.D0.94.D0.B0.D0.BD.D0.BD.D1.8B.D0.B5
	   _HttpSCError_ConvertError2Text  "Http SC Error.inc"    .

:
	#include "Http SC.inc"
	#include "Http SC Error.inc"
	
	Local $sReqest
	$sReqest = 'POST /post.php HTTP/1.1'&@CRLF&'Host: astel064.16mb.com'&@CRLF&'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:56.0) Gecko/20100101 Firefox/56.0'&@CRLF&'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'&@CRLF&'Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3'&@CRLF&'Accept-Encoding: gzip, deflate'&@CRLF&'Content-Type: application/x-www-form-urlencoded'&@CRLF&'Content-Length: 10'&@CRLF&'Connection: keep-alive'&@CRLF&'Upgrade-Insecure-Requests: 1'&@CRLF&'Cache-Control: max-age=0'&@CRLF&@CRLF&'text='
	MsgBox(0,0, _HttpSC_PostReqestGetData($sReqest, 0) )

=========================================================================================================================================

:			_HttpSC_BasicAuthenticate_GetData($sReqest)
:		    BASIC    
:		_HttpSC_BasicAuthenticate_GetData($sReqest)
:
							$sReqest		=    

:				   =  $aArray  2 ,  $aArray[0]=,  $aArray[1]=;     = 0
@Error:				   = 0;     > 0
@Extended:		 0

:
	     :  https://ru.wikipedia.org/wiki/%D0%A1%D0%BF%D0%B8%D1%81%D0%BE%D0%BA_%D0%B7%D0%B0%D0%B3%D0%BE%D0%BB%D0%BE%D0%B2%D0%BA%D0%BE%D0%B2_HTTP#.D0.94.D0.B0.D0.BD.D0.BD.D1.8B.D0.B5
	   _HttpSCError_ConvertError2Text  "Http SC Error.inc"    .

=========================================================================================================================================


























>>>>>>>   <<<<<<<
   "_HttpSC_ServerHandler" (: $sGetFileFunc,  $sPostFunc,  $sOtherFunc, $sUserBanFunc)

------------------------------------------------------------

	: 	$sGetFileFunc
	:	         ( GET)
	 ($sGetFileFunc = "_GetServerFile"):
	
		Func _GetServerFile($sUrl, $hUserSocket, $sUserIp, $sHttpVer, $Reqest)
		Return ""
		EndFunc
	
	,      :
		$sUrl					=    (: "/index.htm",  "/" -  ;   "index.htm" -    )
		$hUserSocket		= ID   
		$sUserIp				= IP   
		$sHttpVer				=  HTTP,    (: "HTTP/1.1").     .
		$sReqest				=   ()
	   ,      "_HttpSC_CreateAnswer",   (    )      .
	     (""),         - .
	           (     )     "_HttpSC_ServerHandler".
	
	
	
	
	:	$sPostFunc
	:	         ( POST)
	 ($sGetFileFunc = "_Post"):
	
		Func _Post($sUrl, $hUserSocket, $sUserIp, $sHttpVer, $Reqest)
		Return ""
		EndFunc
	
	,      :
		$sUrl					=    (: "/" -  )
		$hUserSocket		= ID   
		$sUserIp				= IP   
		$sHttpVer				=  HTTP,    (: "HTTP/1.0").     .
		$sReqest				=   ()
	   ,      "_HttpSC_CreateAnswer",   (    )      .
	     (""),         - .
	           (     )     "_HttpSC_ServerHandler".

	
	
	
	: 	$sOtherFunc
	:	   ,      GET  POST 
	 ($sOtherFunc = "_OtherReqest"):
	
		Func _OtherReqest($hUserSocket, $sUserIp, $Reqest)
		Return ""
		EndFunc
	
	,      :
		$hUserSocket		= ID   
		$sUserIp				= IP   
		$Reqest				=  HTTP,    (: "HTTP/1.1").     .
	
	
	
	: 	$sUserBanFunc
	:	   ,     -       
	 ($sUserBanFunc = "_UserBan"):
	
		Func _UserBan($sUserIp, $sServerSocket, $sServerIp)
		Return
		EndFunc
	
	,      :
		$sUserIp				= IP   
		$sServerSocket	= ID  ,     
		$sServerIp			= Ip  ,     
	
------------------------------------------------------------
	


