Tags:
create new tag
, view all tags

Feature Proposal: CGI Engine to be made Fast CGI compatible

Motivation

http://develop.twiki.org/svn/twiki/trunk/FastCGIEngineContrib introduced bin/twiki_fcgi, which uses TWiki::Engine::FastCGI. This may sound right but TWiki::Engine::FastCGI is not necessary. A minor enhancement to TWiki::Engine::CGI works fine for the purpose. And then you can concentrate Fast CGI-ness in twiki_fcgi.

Description and Documentation

Introducing an optional $cgi parameter to the run() method of the CGI engine.

The top level loop of a Fast CGI program is as follows.

while ( my $cgi = CGI::Fast->new() ) {
...
}
And the $cgi value needs to be handed to the run() method of the TWiki engine. But currently TWiki::Engine::CGI::run() doesn't take a parameter.

If the run() method took a CGI object as an optional parameter, it would be Fast CGI capable.

Impact

Implementation

TWiki::Engine::CGI:

sub run { 
    my ($this, $cgi) = @_;
   $this->{cgi} = $cgi if ( $cgi );
...
sub prepareBody {
    my ( $this, $req ) = @_;

    return if ( $this->{cgi} );

bin/twiki_fcgi would be something like:

use strict;
use warnings;

BEGIN {
    $TWiki::cfg{Engine} = 'TWiki::Engine::CGI';
    use CGI::Carp qw(fatalsToBrowser);
    $SIG{__DIE__} = \&CGI::Carp::confess;
    @INC = ('.', grep { $_ ne '.' } @INC);
    require 'setlib.cfg';
}

use TWiki;
use TWiki::UI;
use CGI::Fast;

while ( my $cgi = CGI::Fast->new() ) {
    if ( defined $ENV{PATH_INFO} ) {
        $ENV{PATH_INFO} =~ s/^(\/\w+)//;
        $ENV{SCRIPT_NAME} .= $1;
        $ENV{TWIKI_ACTION} = substr($1, 1);
    }
    $TWiki::engine->run($cgi);
}

-- Contributors: HideyoImazu - 2012-08-02

Discussion

Edit | Attach | Watch | Print version | History: r7 < r6 < r5 < r4 < r3 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r7 - 2012-09-03 - HideyoImazu
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.