Sign in Join

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

Mailing lists / fpc-pascal / 2015-01

Is Path_Info available in FastCGI working as proxy?

7 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

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

silvioprog

Hello,

I've the same problem in Apache and nginx: TRequest.PathInfo always returns an empty string.

In Apache, I'm using the the mod_proxy_fcgi module already distributed in Apache 24. In nginx, I'm using this configuration:

location /dev/duallsms {
fastcgi_pass localhost:8080;
... other configurations ...
fastcgi_param PATH_INFO $fastcgi_path_info; # from nginx docs }

First I've tested it on Windows, but I've noticed that it fail in Linux too. So I ask: is PATH_INFO available in FastCGI (working as proxy)? If not, what I use instead it?!

Thank you!

Silvio Clécio My public projects - github.com/silvioprog

Reply by email

silvioprog
to silvioprog

Oops, and my test is:

program DuallSMSFastCGITest;
{$mode objfpc}{$H+}
uses
  HttpDefs, CustFCGI;
type
  { TMyFCGIHandler }
  TMyFCGIHandler = class(TFCGIHandler)
  public
    procedure HandleRequest(ARequest: TRequest; AResponse: TResponse);
override;
  end;
  { TMyFCGIHandler }
  procedure TMyFCGIHandler.HandleRequest(ARequest: TRequest; AResponse:
TResponse);
  begin
    AResponse.Contents.Text := 'PathInfo: ' + ARequest.PathInfo;
  end;
begin
  with TMyFCGIHandler.Create(nil) do
  try
    Port := 8080;
    Initialize;
    Run;
  finally
    Free;
  end;
end.

FPC 2.6.4 (and FPC from trunk too).

silvioprog wrote 24 lines
Hello, I've the same problem in Apache and nginx: TRequest.PathInfo always returns an empty string. In Apache, I'm using the the mod_proxy_fcgi module already distributed in Apache 24. In nginx, I'm using this configuration: location /dev/duallsms { fastcgi_pass localhost:8080; ... other configurations ... fastcgi_param PATH_INFO $fastcgi_path_info; # from nginx docs } First I've tested it on Windows, but I've noticed that it fail in Linux too. So I ask: is PATH_INFO available in FastCGI (working as proxy)? If not, what I use instead it?! Thank you! -- Silvio Clécio My public projects - github.com/silvioprog
Silvio Clécio My public projects - github.com/silvioprog

Reply by email

Michael Van Canneyt
to silvioprog: I've the same problem in Apache and nginx: TRequest.PathInfo always returns an empty…
silvioprog wrote 13 lines
Hello, I've the same problem in Apache and nginx: TRequest.PathInfo always returns an empty string. In Apache, I'm using the the mod_proxy_fcgi module already distributed in Apache 24. In nginx, I'm using this configuration: location /dev/duallsms { fastcgi_pass  localhost:8080; ... other configurations ... fastcgi_param PATH_INFO $fastcgi_path_info; # from nginx docs } First I've tested it on Windows, but I've noticed that it fail in Linux too. So I ask: is PATH_INFO available in FastCGI (working as proxy)? If not, what I use instead it?!

PATH_INFO is not always available, you need to configure that in apache and/or nginx.

See http://httpd.apache.org/docs/trunk/mod/mod_proxy_fcgi.html

The FPC fcl-web components by themselves do not try to reconstruct PATH_INFO. You can try determining it from SCRIPT_URI or SCRIPT_NAME.

Michael.

Reply by email

silvioprog
to Michael Van Canneyt

On Thu, Jan 29, 2015 at 6:58 PM, Michael Van Canneyt <

Show quoted text 26 lines
wrote: On Thu, 29 Jan 2015, silvioprog wrote: > Hello, > > I've the same problem in Apache and nginx: TRequest.PathInfo always > returns an empty string. > > In Apache, I'm using the the mod_proxy_fcgi module already distributed in > Apache 24. In nginx, I'm using this configuration: > > location /dev/duallsms { > fastcgi_pass localhost:8080; > ... other configurations ... > fastcgi_param PATH_INFO $fastcgi_path_info; # from nginx docs > } > > First I've tested it on Windows, but I've noticed that it fail in Linux > too. So I ask: is PATH_INFO available in FastCGI (working as proxy)? If > not, what I use instead it?! > PATH_INFO is not always available, you need to configure that in apache and/or nginx.

Thanks for the information.

Show quoted text 5 lines
See http://httpd.apache.org/docs/trunk/mod/mod_proxy_fcgi.html The FPC fcl-web components by themselves do not try to reconstruct PATH_INFO. You can try determining it from SCRIPT_URI or SCRIPT_NAME.

Hm... what do you think about to read it from the REQUEST_URI param? If it is good, you need to do a small change in FCL (if relevant hehe). The patch in attached allows to use the implementation below:

program project1;
{$mode objfpc}{$H+}
uses
  HttpDefs, custfcgi;
type
  { TMyFCGIRequest }
  TMyFCGIRequest = class(TFCGIRequest)
  public
    property CGIParams;
  end;
  { TMyFCGIHandler }
  TMyFCGIHandler = class(TFCGIHandler)
  public
    function CreateRequest: TFCGIRequest; override;
    procedure HandleRequest(ARequest: TRequest; AResponse: TResponse);
override;
  end;
  { TMyFCGIHandler }
  function TMyFCGIHandler.CreateRequest: TFCGIRequest;
  begin
    Result := TMyFCGIRequest.Create;
  end;
  procedure TMyFCGIHandler.HandleRequest(ARequest: TRequest; AResponse:
TResponse);
  begin
    // open "
http://localhost/dev/duallsms/pesquisa/contato?campo=nome&filtro=fulano"
and get
    // the "REQUEST_URI:
/dev/duallsms/pesquisa/contato?campo=nome&filtro=fulano" output
    AResponse.Contents.Text := 'REQUEST_URI: ' +
      TMyFCGIRequest(ARequest).CGIParams.Values['REQUEST_URI'];
  end;
begin
  with TMyFCGIHandler.Create(nil) do
  try
    Port := 8080;
    Run;
  finally
    Free;
  end;
end.
Silvio Clécio My public projects - github.com/silvioprog

Reply by email

silvioprog
to silvioprog
silvioprog wrote 96 lines
On Thu, Jan 29, 2015 at 6:58 PM, Michael Van Canneyt < > wrote: > > On Thu, 29 Jan 2015, silvioprog wrote: > >> Hello, >> >> I've the same problem in Apache and nginx: TRequest.PathInfo always >> returns an empty string. >> >> In Apache, I'm using the the mod_proxy_fcgi module already distributed >> in Apache 24. In nginx, I'm using this configuration: >> >> location /dev/duallsms { >> fastcgi_pass localhost:8080; >> ... other configurations ... >> fastcgi_param PATH_INFO $fastcgi_path_info; # from nginx docs >> } >> >> First I've tested it on Windows, but I've noticed that it fail in Linux >> too. So I ask: is PATH_INFO available in FastCGI (working as proxy)? If >> not, what I use instead it?! >> > > PATH_INFO is not always available, you need to configure that in apache > and/or nginx. > Thanks for the information. > See http://httpd.apache.org/docs/trunk/mod/mod_proxy_fcgi.html > > The FPC fcl-web components by themselves do not try to reconstruct > PATH_INFO. > You can try determining it from SCRIPT_URI or SCRIPT_NAME. Hm... what do you think about to read it from the REQUEST_URI param? If it is good, you need to do a small change in FCL (if relevant hehe). The patch in attached allows to use the implementation below: program project1; {$mode objfpc}{$H+} uses HttpDefs, custfcgi; type { TMyFCGIRequest } TMyFCGIRequest = class(TFCGIRequest) public property CGIParams; end; { TMyFCGIHandler } TMyFCGIHandler = class(TFCGIHandler) public function CreateRequest: TFCGIRequest; override; procedure HandleRequest(ARequest: TRequest; AResponse: TResponse); override; end; { TMyFCGIHandler } function TMyFCGIHandler.CreateRequest: TFCGIRequest; begin Result := TMyFCGIRequest.Create; end; procedure TMyFCGIHandler.HandleRequest(ARequest: TRequest; AResponse: TResponse); begin // open " http://localhost/dev/duallsms/pesquisa/contato?campo=nome&filtro=fulano" and get // the "REQUEST_URI: /dev/duallsms/pesquisa/contato?campo=nome&filtro=fulano" output AResponse.Contents.Text := 'REQUEST_URI: ' + TMyFCGIRequest(ARequest).CGIParams.Values['REQUEST_URI']; end; begin with TMyFCGIHandler.Create(nil) do try Port := 8080; Run; finally Free; end; end.

I'm resending this last question because I'm not sure if my email was delivered.

Silvio Clécio My public projects - github.com/silvioprog

Reply by email

Michael Van Canneyt
to silvioprog
silvioprog wrote 33 lines
On Thu, Jan 29, 2015 at 7:28 PM, silvioprog wrote: On Thu, Jan 29, 2015 at 6:58 PM, Michael Van Canneyt wrote: On Thu, 29 Jan 2015, silvioprog wrote: Hello, I've the same problem in Apache and nginx: TRequest.PathInfo always returns an empty string. In Apache, I'm using the the mod_proxy_fcgi module already distributed in Apache 24. In nginx, I'm using this configuration: location /dev/duallsms { fastcgi_pass  localhost:8080; ... other configurations ... fastcgi_param PATH_INFO $fastcgi_path_info; # from nginx docs } First I've tested it on Windows, but I've noticed that it fail in Linux too. So I ask: is PATH_INFO available in FastCGI (working as proxy)? If not, what I use instead it?! PATH_INFO is not always available, you need to configure that in apache and/or nginx. Thanks for the information.   See http://httpd.apache.org/docs/trunk/mod/mod_proxy_fcgi.html The FPC fcl-web components by themselves do not try to reconstruct PATH_INFO. You can try determining it from SCRIPT_URI  or SCRIPT_NAME. Hm... what do you think about to read it from the REQUEST_URI param? If it is good, you need to do a small change in FCL (if relevant hehe). The patch in attached allows to use the implementation below:

No, that will not happen. This is guesswork.
Whether this will work, will very much depend on the setup.

If you need this, then you should implement the logic for handling REQUEST_URI yourself.

But I am prepared to provide a hook that allows you to determine PATH_INFO yourself if the server did not pass it on, since PATH_INFO is needed to determine the module that must handle the request.

Michael.

Reply by email

silvioprog
to Michael Van Canneyt

On Fri, Jan 30, 2015 at 11:07 AM, Michael Van Canneyt <

Show quoted text 55 lines
wrote: On Fri, 30 Jan 2015, silvioprog wrote: > On Thu, Jan 29, 2015 at 7:28 PM, silvioprog wrote: > On Thu, Jan 29, 2015 at 6:58 PM, Michael Van Canneyt < > > wrote: > On Thu, 29 Jan 2015, silvioprog wrote: > Hello, > > I've the same problem in Apache and nginx: > TRequest.PathInfo always returns an empty string. > > In Apache, I'm using the the mod_proxy_fcgi module > already distributed in Apache 24. In nginx, I'm > using this configuration: > > location /dev/duallsms { > fastcgi_pass localhost:8080; > ... other configurations ... > fastcgi_param PATH_INFO $fastcgi_path_info; # from > nginx docs > } > > First I've tested it on Windows, but I've noticed that > it fail in Linux too. So I ask: is > PATH_INFO available in FastCGI (working as proxy)? If > not, what I use instead it?! > > > PATH_INFO is not always available, you need to configure that > in apache and/or nginx. > > > Thanks for the information. > > See http://httpd.apache.org/docs/trunk/mod/mod_proxy_fcgi.html > > The FPC fcl-web components by themselves do not try to reconstruct > PATH_INFO. > You can try determining it from SCRIPT_URI or SCRIPT_NAME. > > > Hm... what do you think about to read it from the REQUEST_URI param? If > it is good, you need to do a small change in FCL (if > relevant hehe). The patch in attached allows to use the implementation > below: > No, that will not happen. This is guesswork. Whether this will work, will very much depend on the setup. If you need this, then you should implement the logic for handling REQUEST_URI yourself.

Thanks for the info again.

But I am prepared to provide a hook that allows you to determine PATH_INFO yourself if the server did not pass it on, since PATH_INFO is needed to determine the module that must handle the request.

Awesome! =)

Silvio Clécio My public projects - github.com/silvioprog

Reply by email