Giter Club home page Giter Club logo

Comments (23)

silvioprog avatar silvioprog commented on August 19, 2024

UrlFor depends of TRequest.PathInfo, and it must return the current PATH_INFO. Can you execute the test below?:

procedure TMyAction.Request(ARequest: TRequest; AResponse: TResponse);
begin
  Write(ARequest.PathInfo);
end;

initialization
  TMyAction.Register('/a/b'); // call http://localhost/cgi-bin/cgi1/a/b

If you not got /a/b on the browser, the problem is in FCL-Web for FastCGI.

from brookframework.

leledumbo avatar leledumbo commented on August 19, 2024

Yes, I do get /a/b on the browser. THome is registered with '*' pattern (and is set as default), would that be the problem? Since the pathinfo will be / (tested and proven), even if I give a non-existent path (because it's set as default).

from brookframework.

silvioprog avatar silvioprog commented on August 19, 2024

The 'problem' is in the FCL-Web for FastCGI. Using this code below:

procedure TMyAction.Request(ARequest: TRequest; AResponse: TResponse);
begin
  Write(GetEnvironmentVariable('SCRIPT_NAME'));
end;

compiled for CGI and calling http://localhost/cgi-bin/cgi1, the result is: /cgi-bin/cgi1. But, compiled for FastCGI and calling http://localhost/cgi-bin/cgi1, the result is empty.

So the problem isnt in Brook. :/ Open a entry in Free Pascal bugtracker?

from brookframework.

leledumbo avatar leledumbo commented on August 19, 2024

OK, but actually I don't know what's wrong with that. I mean, should SCRIPT_NAME be equal for both?

from brookframework.

silvioprog avatar silvioprog commented on August 19, 2024

I don't think so. :(
Please see: http://www.fastcgi.com/devkit/doc/fcgi-spec.html

from brookframework.

leledumbo avatar leledumbo commented on August 19, 2024

I'm still not sure what to report to FPC mantis (my brain has a problem reading specs :p), could you do that instead?

from brookframework.

silvioprog avatar silvioprog commented on August 19, 2024

I do not feel safe to report this due to limitation of my English. XD
So, what will we do hehehe?

It would be interesting to test a small FastCGI script in another programming language (Perl?) and check if it returns this variable.

from brookframework.

silvioprog avatar silvioprog commented on August 19, 2024

Oh god, Perl FCGI return the SCRIPT_NAME, please see:

http://brookframework.org/test.fbf

Response:

FastCGI Demo Page (perl)

This is coming from a FastCGI server. 
Running on brookframework.org - /test.fbf to XXX
This is connection number 1

The code of this test:

#!/usr/bin/perl -wT

use strict;
use vars qw( $cnt );
use FCGI;

local $cnt = 0;

while ( FCGI::accept >= 0 ) {
  print "Content-type: text/html\r\n\r\n";
  print "<head>\n<title>FastCGI Demo Page (perl)</title>\n</head>\n";
  print  "<h1>FastCGI Demo Page (perl)</h1>\n";
  print "This is coming from a FastCGI server.\n<BR>\n";
  print "Running on <EM>$ENV{SERVER_NAME}-$ENV{SCRIPT_NAME}</EM> to <EM>$ENV{REMOTE_HOST}</EM>\n<BR>\n";
   $cnt++;
  print "This is connection number $cnt\n";
}

from brookframework.

leledumbo avatar leledumbo commented on August 19, 2024

Perhaps this report is enough: SCRIPT_NAME in a FastCGI application returns empty string. What do you think?

from brookframework.

silvioprog avatar silvioprog commented on August 19, 2024

Perfect! Send me the issue link after you submit.

from brookframework.

leledumbo avatar leledumbo commented on August 19, 2024

Could you try this first on Apache? In my Nginx, I don't even find SCRIPT_NAME at all...

from brookframework.

silvioprog avatar silvioprog commented on August 19, 2024

Yes:

http://brookframework.org/project1.fbf

But if I'm not mistaken, the FastCGI not read the informations directly from the environment variables.

But in my mind there is way to solve this easily: BrookSettings.RootUrl. By default this property is filled by SCRIPT_NAME value. It seems a good idea? :)

from brookframework.

silvioprog avatar silvioprog commented on August 19, 2024

This will be implemented as soon as possible. :)

ps. Oh, sorry friend, I accidentally deleted your comment, but I pasted it below (copied from my Gmail). x(

2013/1/7 Mario Ray Mahardhika says:

But if I'm not mistaken, the FastCGI not read the informations directly
from the environment variables.

I'll ask Michael to ensure.

But in my mind there is way to solve this easily: BrookSettings.RootUrl.
By default this property is filled by SCRIPT_NAME value. It seems a good
idea? :)

Filled automatically on each request? Seems good.

from brookframework.

silvioprog avatar silvioprog commented on August 19, 2024

Hello Mario,

Done (685a03e).

Can you test it please?

Thanks! :)

from brookframework.

silvioprog avatar silvioprog commented on August 19, 2024

I implemented it in "working" branch (http://imagebin.org/243220).

from brookframework.

leledumbo avatar leledumbo commented on August 19, 2024

Tested and works, the documentation needs to be expanded though. It should say that RootURL must be filled in order for Redirect (or UrlFor) to work

from brookframework.

silvioprog avatar silvioprog commented on August 19, 2024

Guy, more adjusts: cb3fcb4

Can you help me to add more details on documentation? My translator is still on vacation hehehe...

from brookframework.

silvioprog avatar silvioprog commented on August 19, 2024

Nice?:

(...)
    { Set the default root URL. This is used by methods such as
      @code(TBrookAction.UrlFor), @code(TBrookActionHelper.LinkTo),
      @code(TBrookActionHelper.ButtonTo) etc. By default, Brook assumes
      @code(SCRIPT_NAME) as root URL. }
    RootUrl: string;
(...)

from brookframework.

leledumbo avatar leledumbo commented on August 19, 2024

By default, Brook assumes @code(SCRIPT_NAME) as root URL

Just to be sure, which code fills this field when it's empty?

from brookframework.

silvioprog avatar silvioprog commented on August 19, 2024

In the router:

1 - https://github.com/silvioprog/brookframework/blob/master/core/brookrouter.pas#L360
2 - https://github.com/silvioprog/brookframework/blob/master/core/brookrouter.pas#L368

from brookframework.

silvioprog avatar silvioprog commented on August 19, 2024

The new "pasdoc comment" for documentation is good?

from brookframework.

leledumbo avatar leledumbo commented on August 19, 2024

OK, then it's good.

from brookframework.

silvioprog avatar silvioprog commented on August 19, 2024

Done (538afb4). Thank you friend!

from brookframework.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.