9 use HTTP::Request::AsCGI;
12 $SIG{'PIPE'} = 'IGNORE';
14 my $server = HTTP::Daemon->new( LocalPort => 3000, ReuseAddr => 1 ) || die;
16 print "Please contact me at: <URL:", $server->url, ">\n";
18 while ( my $client = $server->accept ) {
21 REMOTE_ADDR => $client->peerhost,
22 REMOTE_HOST => $client->peerhost,
23 REMOTE_PORT => $client->peerport
26 while ( my $request = $client->get_request ) {
28 CGI::initialize_globals();
30 $request->uri->scheme('http');
31 $request->uri->host_port( $request->header('Host') || URI->new($server)->host_port );
33 my $c = HTTP::Request::AsCGI->new( $request, %e )->setup;
36 print $q->header( -charset => 'UTF-8' ),
38 -title => 'Hello World',
41 $q->h1('Hello World'),
45 $q->td( [ 'Name', $q->textfield( -name => 'name' ) ] ),
46 $q->td( [ 'Email', $q->textfield( -name => 'email' ) ] ),
47 $q->td( [ 'Phone', $q->textfield( -name => 'phone' ) ] ),
48 $q->td( [ 'File', $q->filefield( -name => 'file' ) ] )
57 my $response = $c->restore->response;
59 # tell client to close socket to prevent blocking problems
60 # in this single threaded daemon.
61 $response->header( Connection => 'close' );
63 $client->send_response($response);