[fpc-pascal] Re: No access to Embedded FPC HTTP server on Vista orWin7
Michael Van Canneyt
michael at freepascal.org
Mon Oct 28 11:12:24 CET 2013
On Mon, 28 Oct 2013, Graeme Geldenhuys wrote:
>
>
> Regards, - Graeme -
>
>
>
> On Monday 28/10/2013 at 11:38, Michael Van Canneyt wrote:
> Damn windows Firewall :(
>
>
> That's what I thought too... but maybe I was wrong. My bad!
>
> Does the request arrive at all in the webserver app ? i.e. does the Accept() call return ?
>
>
> For some reason I was concentrating on debugging the CGI client applications, thinking the problem is maybe there, or a Windows Firewall or Windows permission issue. After reading your reply I adding loads of
> debug log() lines in the webserver app, and it seems that the repeat...until loop that reads the TProcess output from the CGI app never exits. Any ideas on why this is for Vista or Win7 OSes?
>
>
> Here is the code that executes the CGI app, reads the CGI output and sends the Response content.
>
> ---------------------------
> procedure TFPCustomCGIModule.ExecuteCGIApp(ARequest: TRequest;
> AResponse: TResponse; const ACGIApp: string);
> const
> BufSize = 1024;
> var
> p: TProcess;
> Buf: string;
> Count: integer;
> lResponse: string;
> i: integer;
> begin
> Log('>> TFPCustomCGIModule.ExecuteCGIApp', lsDebug);
> p := TProcess.Create(nil);
>
> with p.Environment do
> begin
> // set lots of environment variables required for CGI applications to work
> ...snip...
> end;
>
> p.Options := [poUsePipes, poStdErrToOutPut, poNoConsole];
> p.ShowWindow := swoShowNormal;
> p.CurrentDirectory := ExtractFilePath(ACGIApp);
> p.CommandLine := ACGIApp + ' ' + ARequest.QueryString;
> try
> p.Execute;
> Log('p.Execute called', lsDebug); // <---- I see this is the log output, but nothing further...
> { Now process the output }
> lResponse := '';
> SetLength(Buf,BufSize);
> repeat
> if (p.Output<>nil) then
> begin
> Count := p.Output.Read(Buf[1],Length(Buf));
> lResponse := lResponse + Copy(Buf,1, Count);
> end
> else
> Count:=0;
> until Count=0;
> Log('repeat..until Count=0 returned', lsDebug); // <----- Under Vista and Win7 it never gets here??
Aha.
Probably, user account control (UAC) is to blame for this.
Maybe there is some dialog 'Do you want to allow this program to execute?' or somesuch.
That can be tested easily:
Try switching off UAC, see if it works then.
If so, we'll know in what direction to look...
Michael.
More information about the fpc-pascal
mailing list