[fpc-pascal] Using areq.getnextpathinfo in a CGI module

Luciano de Souza luchyanus at gmail.com
Tue Nov 1 23:03:39 CET 2011


Hello listers,

I am trying to understand how to create some code using Custcgi. 
However, the following peace is not clear for me concerning to 
"getnextpathinfo". Let's see:

program cgiproject1;

{$mode objfpc}{$H+}

uses
   HTTPDefs, custweb, custcgi, main;

type

   { TMyCGIHandler }

   TMyCGIHandler = class(TCGIHandler)
   public
     procedure HandleRequest(AReq: TRequest; ARes: TResponse); override;
   end;

   TMyCGIApp = class(TCustomCGIApplication)
   protected
     function InitializeWebHandler: TWebHandler; override;
   end;

procedure TMyCGIHandler.HandleRequest(AReq: TRequest; ARes: TResponse);
begin
   if AReq.GetNextPathInfo = 'test' then
     CGITest(AReq, ARes)
   else
     CGIAbreHtml(AReq, ARes);
end;

function TMyCGIApp.InitializeWebHandler: TWebHandler;
begin
   Result := TMyCGIHandler.Create(self);
end;

begin
   With TMyCGIApp.Create(Nil) do
     try
       Initialize;
       Run;
     finally
       Free;
     end;
end.

The code seems to be logical. I created a tCGIApplication derived from 
tCustomApplication, in other words, the object responsible for the 
program initialization.

By means of "initializeWebHandler", a tCGIHandler object is created. Of 
course, this is the responsible for requests and responses handling.

Everything is good until:

if AReq.GetNextPathInfo = 'test' then
     CGITest(AReq, ARes)
   else
     CGIAbreHtml(AReq, ARes);
en

What does it mean "AReq.GetNextPathInfo = 'test'"?

Best regards,

Luciano



More information about the fpc-pascal mailing list