PageRenderTime 30ms CodeModel.GetById 7ms app.highlight 18ms RepoModel.GetById 2ms app.codeStats 0ms

/examples/lighty/test_fastcgi.pl

http://github.com/http-engine/HTTP-Engine
Perl | 52 lines | 43 code | 8 blank | 1 comment | 0 complexity | d522d1a511b346b95332d574e19c0e58 MD5 | raw file
 1#!/usr/bin/perl
 2use strict;
 3use warnings;
 4use FindBin '$Bin';
 5use HTTP::Engine;
 6use Data::Dumper;
 7use Getopt::Long;
 8
 9GetOptions(
10    \my %option,
11    qw/listen=s/
12);
13
14HTTP::Engine->new(
15    interface => {
16        module => 'FCGI',
17        args   => {
18            $option{listen} ? (
19                listen => $option{listen},
20                nproc  => 1,
21            ) : (),
22        },
23        request_handler => sub {
24            my $req = shift;
25
26            my $res = HTTP::Engine::Response->new;
27            $res->content_type('text/html');
28            $res->body( render_body( Dumper($req) ) );
29            $res;
30         }
31    },
32)->run;
33
34sub render_body {
35    my @args = @_;
36
37    my $body = <<"...";
38        <form method="post">
39            <input type="text" name="foo" />
40            <input type="submit" />
41        </form>
42
43        <form method="post" enctype="multipart/form-data">
44            <input type="file" name="upload_file" />
45            <input type="submit" />
46        </form>
47...
48
49    $body .= join '', map { "<pre>$_</pre>" } @args;
50    $body;
51}
52