Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2013-10

Re: Re: No access to Embedded FPC HTTP server on Vista orWin7

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Graeme Geldenhuys

Regards,
- Graeme -

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.Outputnil) 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??
    p.WaitOnExit;
    Log('p.WaitOnExit returned', lsDebug);
  finally
    p.Free;
    AResponse.Content := lResponse;
    AResponse.Code := p.ExitStatus;
    Log('About to do:  AResponse.SendContent', lsDebug);
    AResponse.SendContent;
    Log('Content successfully sent!', lsDebug);
    AResponse.ContentStream := nil;
  end;
  Log('<< TFPCustomCGIModule.ExecuteCGIApp', lsDebug);
end;
---------------------------

I'm using FPC 2.6.2 32-bit. I'm going to compare my "reading console output" code to the code found in TIOStream class (which I only discovered a few days ago). Maybe that reveals something I'm doing wrong.

Regards,
Graeme.

Reply by email

Michael Van Canneyt
to Graeme Geldenhuys
Graeme Geldenhuys wrote 62 lines
    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.Outputnil) 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.

Reply by email