Skip to content

Commit c4a092a

Browse files
- retirada do autocreate das ResponsePages do servidor, para nao ficar dando diferença entre versao compilada versao do conteudo
- implmentado no SynopseServer o evento OnTerminate para identificar queda no servidor
1 parent 6d619e2 commit c4a092a

3 files changed

Lines changed: 14 additions & 3 deletions

File tree

src/base/RALServer.pas

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,6 @@ constructor TRALServer.Create(AOwner: TComponent);
431431
FShowServerStatus := True;
432432
FCookieLife := 30;
433433
FSSL := CreateRALSSL;
434-
435-
ResponsePages.CreateDefaultPages;
436434
end;
437435

438436
function TRALServer.CreateRALSSL: TRALSSL;

src/engine/synopse/RALSynopseServer.pas

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ TRALSynopseServer = class(TRALServer)
4646
procedure SetSSL(const AValue: TRALSynopseSSL);
4747
function OnCommandProcess(AContext: THttpServerRequestAbstract): Cardinal;
4848
function OnSendFile(AContext: THttpServerRequestAbstract; const LocalFileName: TFileName): boolean;
49+
procedure OnHttpTerminate(ASender : TObject);
4950
public
5051
constructor Create(AOwner: TComponent); override;
5152
destructor Destroy; override;
@@ -96,6 +97,7 @@ procedure TRALSynopseServer.SetActive(const AValue: boolean);
9697
FHttp.HttpQueueLength := FQueueSize;
9798
FHttp.OnSendFile := {$IFDEF FPC}@{$ENDIF}OnSendFile;
9899
FHttp.ServerName := 'RAL_Mormot2';
100+
FHttp.OnTerminate := {$IFDEF FPC}@{$ENDIF}OnHttpTerminate;
99101
// FHttp.RegisterCompressGzStatic := True;
100102
FHttp.OnRequest := {$IFDEF FPC}@{$ENDIF}OnCommandProcess;
101103
if SSL.Enabled then
@@ -312,6 +314,11 @@ function TRALSynopseServer.OnSendFile(AContext: THttpServerRequestAbstract;
312314
Result := True;
313315
end;
314316

317+
procedure TRALSynopseServer.OnHttpTerminate(ASender: TObject);
318+
begin
319+
Active := False;
320+
end;
321+
315322
constructor TRALSynopseServer.Create(AOwner: TComponent);
316323
begin
317324
inherited;

src/utils/RALResponsePages.pas

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,23 @@ function TRALResponsePages.GetHTMLPage(AStatusCode: IntegerRAL): StringRAL;
4848
var
4949
vInt: IntegerRAL;
5050
vPage: TRALResponsePage;
51+
vFind: boolean;
5152
begin
5253
Result := '';
54+
vFind := False;
5355
for vInt := 0 to Pred(Count) do
5456
begin
5557
vPage := TRALResponsePage(Items[vInt]);
5658
if vPage.StatusCode = AStatusCode then
5759
begin
5860
Result := vPage.Page.Text;
59-
Exit;
61+
vFind := True;
62+
Break;
6063
end;
6164
end;
65+
66+
if not vFind then
67+
Result := GetHTTPResponsePage(AStatusCode);
6268
end;
6369

6470
constructor TRALResponsePages.Create(AOwner: TPersistent);

0 commit comments

Comments
 (0)