CPAN-Mini-Inject

 view release on metacpan or  search on metacpan

t/lib/Local/localserver.pm  view on Meta::CPAN


	return $child_pid unless $child_pid == 0;

	require HTTP::Daemon;
	require HTTP::Date;
	require HTTP::Status;

	my $d = HTTP::Daemon->new( LocalPort => $port ) or exit;
	CONNECTION: while (my $c = $d->accept) {
		REQUEST: while (my $r = $c->get_request) {
			my $file = (split m|/|, $r->uri->path)[-1] // 'index.html';
			my $path = catfile 't', 'html', $file;

			if ($r->method eq 'GET') {
				if( -e $path ) {
					$c->send_file_response( catfile 't', 'html', $file);
					}
				elsif( $path eq 'shutdown' ) {
					$c->close; undef $c;
					last CONNECTION;
					}



( run in 0.377 second using v1.01-cache-2.11-cpan-d7a12ab2c7f )