BTW, this is little bit weired that in Delphi, setting "Handled :- true" stops all following operations as far as I know. But in Lazarus, it does not. It's quite long ago when I wrote Delphi codes, so I do not want to check this again.
Hi,
Thank you @egsuh.
I think like you. But don't have the precise explanation.
The only thing I'm sure with the affectation "Handled:= true\false", is that when Handled == false, whereas the code is coming back again in the calling TWebAction that answers first because it was corresponding to the PATHINFO environment variable, or whereas it goes away i.e. it "shunts" its calling TWebAction because it meets
SendContent; (
Redirect; too, I guess???), then the HTML code sent back toward the browser is always empty, even if AResponse.Content has been affected.
I, too, have read many examples that start mechanically with the line "Handled:= true;". And I have also reproduced it mechanically ("Monkey see, Monkey do"). I guess it's didactic. It's to prevent people like me from spending a whole day coding ... an empty answer in the browser
.
So, the example above, should be:
procedure Tgo_uiCtrlFoo.uiActDoThis_onRequest(Sender: TObject; ARequest: TRequest; AResponse: TResponse; var Handled: Boolean);
begin
if something_is_not_ok then
uiAct403Forbidden_onRequest(Sender, ARequest, AResponse, Handled);
// if *only* something is ok, then i continue
Handled:= true; // <==(!!!) more logical here, after any possible "shunt" of the callstack.
...\...
end;
procedure Tgo_uiCtrlFoo.uiAct403Forbidden_onRequest(Sender: TObject; ARequest: TRequest; AResponse: TResponse; var Handled: Boolean);
begin
Handled:= True;
with AResponse do begin
Code:= 403;
CodeText:= 'Forbidden';
Content:= '<HTML>'+
'<HEAD>'+
'<META CONTENT="text/html; charset=UTF-8" http-equiv="content-type">'+
'<TITLE>Forbidden</TITLE>'+
'</HEAD>'+
'<BODY>'+
'<P><B>403</B>: URL forbidden.</P>'+
'</BODY>'+
'</HTML>';
Session.Terminate; // Here, I want too, to clear the "Pascal_SESSION" i.e. Self.Session
SendContent; //|--◉ I do not want to return into the caller (i.e. into uiActDoThis_onRequest)!
end;
end;
Have you ever running FastCGI server? If you have much experience, please share it with me. My CGI server runs well, but fCGI seems to lag sometimes, so that the web-server sends errors, and resume after a few minutes.
No, sorry: I'm currently only writing a CGI application. If its loading in memory becomes problematic because there is too much traffic, then I'll can still migrate it to fast-CGI, before looking for other solutions.