APR-Emulate-PSGI

 view release on metacpan or  search on metacpan

README.pod  view on Meta::CPAN


=over 4

=item headers_out

Emulates L<Apache2::RequestRec/headers_out>.


=cut

=item err_headers_out

Emulates L<Apache2::RequestRec/err_headers_out>.


=cut

=item no_cache

Emulates L<Apache2::RequestUtil/no_cache>.


=cut

inc/Module/Install.pm  view on Meta::CPAN

	# all of the following checks should be included in import(),
	# to allow "eval 'require Module::Install; 1' to test
	# installation of Module::Install. (RT #51267)
	#-------------------------------------------------------------

	# Whether or not inc::Module::Install is actually loaded, the
	# $INC{inc/Module/Install.pm} is what will still get set as long as
	# the caller loaded module this in the documented manner.
	# If not set, the caller may NOT have loaded the bundled version, and thus
	# they may not have a MI version that works with the Makefile.PL. This would
	# result in false errors or unexpected behaviour. And we don't want that.
	my $file = join( '/', 'inc', split /::/, __PACKAGE__ ) . '.pm';
	unless ( $INC{$file} ) { die <<"END_DIE" }

Please invoke ${\__PACKAGE__} with:

	use inc::${\__PACKAGE__};

not:

	use ${\__PACKAGE__};

inc/Module/Install.pm  view on Meta::CPAN

	# is unreliable on some platforms and requires write permissions)
	# for now we should catch this and refuse to run.
	if ( -f $0 ) {
		my $s = (stat($0))[9];

		# If the modification time is only slightly in the future,
		# sleep briefly to remove the problem.
		my $a = $s - time;
		if ( $a > 0 and $a < 5 ) { sleep 5 }

		# Too far in the future, throw an error.
		my $t = time;
		if ( $s > $t ) { die <<"END_DIE" }

Your installer $0 has a modification time in the future ($s > $t).

This is known to create infinite loops in make.

Please correct this, then run $0 again.

END_DIE

inc/Module/Install.pm  view on Meta::CPAN

			goto &$code unless $cwd eq $pwd;
		}
		unless ($$sym =~ s/([^:]+)$//) {
			# XXX: it looks like we can't retrieve the missing function
			# via $$sym (usually $main::AUTOLOAD) in this case.
			# I'm still wondering if we should slurp Makefile.PL to
			# get some context or not ...
			my ($package, $file, $line) = caller;
			die <<"EOT";
Unknown function is found at $file line $line.
Execution of $file aborted due to runtime errors.

If you're a contributor to a project, you may need to install
some Module::Install extensions from CPAN (or other repository).
If you're a user of a module, please contact the author.
EOT
		}
		my $method = $1;
		if ( uc($method) eq $method ) {
			# Do nothing
			return;

inc/Module/Install/Makefile.pm  view on Meta::CPAN

				foreach my $skey (keys %{ $new_args{$key} }) {
					$args->{$key}{$skey} = $new_args{$key}{$skey};
				}
			}
			elsif ($makemaker_argtype{$key} eq 'APPENDABLE') {
				$self->makemaker_append($key => $new_args{$key});
			}
		}
		else {
			if (defined $args->{$key}) {
				warn qq{MakeMaker attribute "$key" is overriden; use "makemaker_append" to append values\n};
			}
			$args->{$key} = $new_args{$key};
		}
	}
	return $args;
}

# For mm args that take multiple space-seperated args,
# append an argument to the current list.
sub makemaker_append {

inc/Module/Install/Makefile.pm  view on Meta::CPAN

		eval "use $perl_version; 1"
			or die "ERROR: perl: Version $] is installed, "
			. "but we need version >= $perl_version";

		if ( $self->makemaker(6.48) ) {
			$args->{MIN_PERL_VERSION} = $perl_version;
		}
	}

	if ($self->installdirs) {
		warn qq{old INSTALLDIRS (probably set by makemaker_args) is overriden by installdirs\n} if $args->{INSTALLDIRS};
		$args->{INSTALLDIRS} = $self->installdirs;
	}

	my %args = map {
		( $_ => $args->{$_} ) } grep {defined($args->{$_} )
	} keys %$args;

	my $user_preop = delete $args{dist}->{PREOP};
	if ( my $preop = $self->admin->preop($user_preop) ) {
		foreach my $key ( keys %$preop ) {

lib/APR/Emulate/PSGI.pm  view on Meta::CPAN


Emulates L<Apache2::RequestRec/headers_out>.

=cut

sub headers_out {
    my ($self) = @_;
    return $self->{'headers_out'} //= APR::MyTable::make();
}

=item err_headers_out

Emulates L<Apache2::RequestRec/err_headers_out>.

=cut

sub err_headers_out {
    my ($self) = @_;
    return $self->{'err_headers_out'} //= APR::MyTable::make();
}

=item no_cache

Emulates L<Apache2::RequestUtil/no_cache>.

=cut

sub no_cache {
    my ($self, $value) = @_;

t/10_psgi.t  view on Meta::CPAN

use strict;
use warnings;

use Test::More;
use APR::Emulate::PSGI;
use IO::File;

plan('tests' => 21);

# Set up filehandles needed in the PSGI environment.
my $error_string;
my $request_body = 'hello=world';
my $response_body = 'howdy';
open my $fh_in, '<', \do { $request_body };
open my $fh_errors, '>', \$error_string;

# Set up PSGI environment.
my $psgi_env = {
    'REMOTE_ADDR'    => '192.168.1.1',
    'REQUEST_METHOD' => 'POST',
    'CONTENT_TYPE'   => 'application/x-www-form-urlencoded',
    'CONTENT_LENGTH' => length($request_body),
    'HTTP_HOK'       => 'gahaha',
    'psgi.errors'    => $fh_errors,
    'psgi.input'     => $fh_in,
};

# Create instance.
my $r = APR::Emulate::PSGI->new($psgi_env);

isa_ok(
    $r,
    'APR::Emulate::PSGI',
    'Object is instantiated.',

t/20_cgi_mode.t  view on Meta::CPAN

use strict;
use warnings;

use Test::More;
use APR::Emulate::PSGI;
use IO::File;

plan('tests' => 16);

# Set up filehandles needed in the PSGI environment.
my $error_string;
my $request_body = 'hello=world';
my $response_body = 'howdy';
open my $fh_in, '<', \do { $request_body };
open my $fh_errors, '>', \$error_string;

# Set up CGI environment.
$ENV{'REMOTE_ADDR'}    = '192.168.1.1';
$ENV{'REQUEST_METHOD'} = 'POST';
$ENV{'CONTENT_TYPE'}   = 'application/x-www-form-urlencoded';
$ENV{'CONTENT_LENGTH'} = length($request_body);
$ENV{'HTTP_HOK'}       = 'gahaha';

# Create instance.
my $r = APR::Emulate::PSGI->new();  # In CGI mode, no environment is passed in.



( run in 1.021 second using v1.01-cache-2.11-cpan-49f99fa48dc )