Func MultipleConnections($address); <-- Function can only make ONE SINGLE connection at a time.
$oMyError = ObjEvent("AutoIt.Error", "httperror"); <-- this line needs to be near the top under #includes.
Local $oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$oHTTP.Open("GET", $address, False)
$oHTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:55.0) Gecko/20100101 Firefox/55.0")
$oHTTP.SetRequestHeader("Accept", "*/*")
$oHTTP.SetRequestHeader("Accept-Language", "tr-TR,tr;q=0.8,en-US;q=0.5,en;q=0.3")
; These are not needed for making a REQUEST
; -----------------------------------------
;$oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded"); <- not sending anything
;$oHTTP.SetRequestHeader("X-Requested-With", "XMLHttpRequest"); <- doubt this would help at all
;$oHTTP.SetRequestHeader("Referer", "https://www.autoitscript.com/forum/"); <- no need
;$oHTTP.SetRequestHeader("Content-Length", "34"); <- one length for all? not needed here
;$oHTTP.SetRequestHeader("Connection", "keep-alive"); <- not needed
$oHTTP.Send()
If @error Then
ConsoleWrite("Error connection")
$oHTTP = 0
Return SetError(1); <-- triggers an error. (code above function needs error checking)
EndIf
If $oHTTP.Status = 200 Then
Local $sReceived = $oHTTP.ResponseText
$oHTTP = Null; <-- use 0 instead
Return $sReceived
EndIf
$oHTTP = Null; <-- use 0 instead
Return -1
EndFunc
Func httperror()
ConsoleWrite("http error" & @CRLF)
$oMyError.Clear; <-- clears the error
Return SetError(1); <-- triggers an error
EndFunc