[fpc-pascal] Is Path_Info available in FastCGI working as proxy?
silvioprog
silvioprog at gmail.com
Thu Jan 29 23:28:14 CET 2015
On Thu, Jan 29, 2015 at 6:58 PM, Michael Van Canneyt <michael at freepascal.org
> 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.
--
Silvio Clécio
My public projects - github.com/silvioprog
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20150129/864b6fb6/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-fcl-web-extends-the-TFCGIRequest-class-allowing-to-u.patch
Type: application/octet-stream
Size: 1251 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20150129/864b6fb6/attachment.obj>
More information about the fpc-pascal
mailing list