Show
Ignore:
Timestamp:
11/12/08 11:04:28 (5 years ago)
Author:
tokuhirom
Message:

r31833@gp: tokuhirom | 2008-11-12 10:48:43 +0900
CGI らしく処理をする。

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/MENTA/trunk/bin/cgi-server.pl

    r23273 r23281  
    22use strict; 
    33use warnings; 
    4 use lib 'vender/lib'; 
     4use lib 'vender/lib', 'lib'; 
    55require HTTP::Server::Simple::CGI; 
    66use POSIX; 
     7use MENTA::BindSTDOUT; 
    78 
    89{ 
    910    package MENTA::Server; 
    1011    use base qw/HTTP::Server::Simple::CGI/; 
     12    use HTTP::Response; 
    1113    sub handle_request { 
    1214        my $pid = fork(); 
     
    1517        } elsif ($pid == 0) { 
    1618            system 'bin/menta.pl'; 
    17             do 'out/index.cgi'; 
    18             die $@ if $@; 
     19            my $out = MENTA::BindSTDOUT->bind(sub { 
     20                do 'out/index.cgi'; 
     21                die $@ if $@; 
     22            }); 
     23            my $res = HTTP::Response->parse("HTTP/1.0 200 OK\n$out"); 
     24            if (my $status = $res->header('Status')) { 
     25                $res->code($status); 
     26                $res->message(HTTP::Status::status_message($status)); 
     27            } 
     28            print $res->as_string; 
    1929            exit; 
    2030        } elsif (defined $pid) {