Forum Discussion
radov
Staff
15 years agoHi Vladimir,
The following code is a DelphiScript version of the function. Note that I've modified a bit the original program logic of the code posted earlier by Igor. However, you can change the code of the function if you need and implement your own program logic in it.
Does this help?
The following code is a DelphiScript version of the function. Note that I've modified a bit the original program logic of the code posted earlier by Igor. However, you can change the code of the function if you need and implement your own program logic in it.
function HttpGet(url, userAgent): boolean;
var
httpObj: OleVariant;
begin
httpObj := Sys.OleObject['MSXML2.XMLHTTP'];
httpObj.open('GET', url, true);
httpObj.setRequestHeader('User-Agent', userAgent); // set user agent
httpObj.setRequestHeader('If-Modified-Since', 'Sat, 1 Jan 2000 00:00:00 GMT'); /// do not cache the response
httpObj.send();
while(httpObj.readyState <> 4) do
Delay(300);
case httpObj.status of
200, 302 :
if Length(httpObj.responseText) <> 0 then
begin
Log.Message('The ' + url + ' link is valid', httpObj.responseText);
Result := false;
end
else
Result := true;
else
begin
Log.Message('The ' + url + ' link was not found, the returned status: ' +
aqConvert.VarToStr(httpObj.status), httpObj.responseText);
Result := false;
end
end
end;
Does this help?