В коде метода локальная переменная MI никак не настраивается в начале, но в ходе исполнения ее значение анализируется

Смотреть-читать код снизу вверх!
- Код: Выделить всё
procedure TWebHandler.HandleRequest(ARequest: TRequest; AResponse: TResponse);
Var
MC : TCustomHTTPModuleClass;
M : TCustomHTTPModule;
MN : String;
MI : TModuleItem;
begin
try
MC:=Nil;
M:=NIL;
If (OnGetModule<>Nil) then OnGetModule(Self,ARequest,MC);
If (MC=Nil) then // *** А если сюда не надо было заходить, так как 'OnGetModule()' установил нужный класс в MC?
begin
MN:=GetModuleName(ARequest);
MI:=ModuleFactory.FindModule(MN); //*** Вроде, только тут?!
if (MI=Nil) then Raise EFPWebError.CreateFmt(SErrNoModuleForRequest,[MN]);
MC:=MI.ModuleClass;
end;
M := FindModule(MC); // Check if a module exists already
If (M = Nil) then
if Mi.SkipStreaming // *** Анализ значения переменной! А где ее значение было указано?
then M := MC.CreateNew(Self)
else M := MC.Create(Self);
SetBaseURL(M,MN,ARequest);
if M.Kind = wkOneShot
then
begin
try
M.HandleRequest(ARequest,AResponse);
finally
M.Free;
end;
end
else
M.HandleRequest(ARequest,AResponse);
except
On E : Exception do
ShowRequestException(AResponse,E);
end;
end;
Для себя исправил так (может, кому еще пригодится):
- Код: Выделить всё
procedure TWebHandler.HandleRequest(ARequest: TRequest; AResponse: TResponse);
Var
MC : TCustomHTTPModuleClass;
M : TCustomHTTPModule;
MN : String;
MI : TModuleItem;
begin
try
MC:=Nil;
M:=NIL;
MI := Nil;
If (OnGetModule<>Nil) then OnGetModule(Self,ARequest,MC);
If (MC=Nil) then
begin
MN:=GetModuleName(ARequest);
MI:=ModuleFactory.FindModule(MN);
if (MI=Nil) then Raise EFPWebError.CreateFmt(SErrNoModuleForRequest,[MN]);
MC:=MI.ModuleClass;
end;
M := FindModule(MC); // Check if a module exists already
If (M = Nil) then
if (MI <> Nil) and (MI.SkipStreaming)
then M := MC.CreateNew(Self)
else M := MC.Create(Self);
SetBaseURL(M,MN,ARequest);
if M.Kind = wkOneShot
then
begin
try
M.HandleRequest(ARequest,AResponse);
finally
M.Free;
end;
end
else
M.HandleRequest(ARequest,AResponse);
except
On E : Exception do
ShowRequestException(AResponse,E);
end;
end;
В итоге - очень удобно получилось и все работает! Можно даже попробовать заявить: PHP Must Die
