I am trying to create an app where IdHTTP can login on a remote machine (no HTTPS needed)
I have written this code:
procedure TForm1.IdHTTPProxyAuthorization(Sender: TObject;
Authentication: TIdAuthentication; var Handled: Boolean);
begin
Handled := True;
end;
procedure TForm1.IdHTTPStatus(ASender: TObject; const AStatus: TIdStatus;
const AStatusText: string);
begin
Memo1.Lines.Add('Status: '+ AStatusText);
end;
procedure TForm1.Button1Click(Sender: TObject);
Var
IdHTTP : TIdHTTP;
Resp : string;
begin
IdHTTP := TIdHTTP.Create;
try
try
with IdHTTP do
begin
OnStatus := @IdHTTPStatus;
OnProxyAuthorization := @IdHTTPProxyAuthorization;
HTTPOptions := [hoInProcessAuth];
ProtocolVersion := pv1_0;
ProxyParams.BasicAuthentication := False;
ProxyParams.ProxyServer := '999.999.99.999';
ProxyParams.ProxyPort := 8080;
ProxyParams.ProxyUsername := 'USER';
ProxyParams.ProxyPassword := 'USER';
//HandleRedirects probably only necessary in this demo
HandleRedirects := True;
end;
// Connect to Open ATV (Linux) unit
Resp := IdHTTP.Get('http://999.999.99.999:9999/?logpoll.html?lastid=0');
Memo1.Lines.Add('Response: '+ Resp);
except
on e : Exception do
begin
Memo1.Lines.Add('Error:' + e.Message);
end;
end;
finally
Freeandnil(IdHTTP);
end;
end;
This is the results I am getting:
Status: Connecting to 999.999.99.999.
Status: Connected.
Status: Disconnected.
Error:HTTP/1.0 401 Unauthorized
Just confused on what I am missing/doing wrong ..................
Any help appreciated in advance
Found another solution with HTTPsend