In the IWServerControllerBaseCloseSession I need to be able to call a url to close a session on an identity server. (I do not need to redirect the user. I only need to call the url)
Has anyone already done this?
Thanks.
IntraWeb has utility classes to perform this task:
Code:
implementation
{$R *.dfm}
uses
IWInit, IWGlobal, IW.Common.Threads, IW.HTTP.IndyClient;
{ TIWServerController }
procedure TIWServerController.IWServerControllerBaseCloseSession(
aSession: TIWApplication);
begin
if Assigned(aSession) then
begin
TIWThreadBase.ExecInThread(
procedure (AThread: TObject)
var
IndyClient: TIWHTTPClient;
begin
IndyClient := TIWHTTPClient.Create;
try
IndyClient.Get('http(s)://yourserver.com/theurl');
// or
// IndyClient.Post('http(s)://yoursever.com/theurl', 'Param1=Value1'); // there are 2 other overloads of this
finally
IndyClient.Free;
end;
end,
'Thread_' + aSession.AppID); // <- the name of the thread is just nice to have
end;
end;
In this code I use the TIWHttpClient to send a GET or POST request to some arbitrary URL from a Thread (so it won't block the termination of the session - have in mind that connection to a different server, especially using HTTPS, can take a long time).
HTTPS connections also require OpenSSL DLLs available in the same directory where your application is.
Thanks. That looks like it is exactly what we needed.