Apache-Emulator
view release on metacpan or search on metacpan
lib/Apache/Emulator/Apache.pm view on Meta::CPAN
return unless $langs;
my $h = shift->headers_out;
for my $l (@$langs) {
$h->add('Content-Language', $l);
}
}
sub status {
shift->header_out('Status', @_);
}
sub status_line {
# What to do here? Should it be managed differently than status?
my $self = shift;
if (@_) {
my $status = shift =~ /^(\d+)/;
return $self->header_out('Status', $status);
}
return $self->header_out('Status');
}
sub headers_out {
my $self = shift;
return wantarray ? %{$self->{headers_out}} : $self->{headers_out};
}
sub header_out {
my ($self, $header) = (shift, shift);
my $h = $self->headers_out;
return @_ ? $h->set($header, shift) : $h->get($header);
}
sub err_headers_out {
my $self = shift;
return wantarray ? %{$self->{err_headers_out}} : $self->{err_headers_out};
}
sub err_header_out {
my ($self, $err_header) = (shift, shift);
my $h = $self->err_headers_out;
return @_ ? $h->set($err_header, shift) : $h->get($err_header);
}
sub no_cache {
my $self = shift;
$self->header_out(Pragma => 'no-cache');
$self->header_out('Cache-Control' => 'no-cache');
}
sub print {
print @_;
}
sub send_fd {
my ($self, $fd) = @_;
local $_;
print STDOUT while defined ($_ = <$fd>);
}
# Should this perhaps throw an exception?
# sub internal_redirect {}
# sub internal_redirect_handler {}
# Do something with ErrorDocument?
# sub custom_response {}
# I think we'ev made this essentially the same thing.
BEGIN {
local $^W;
*send_cgi_header = \&send_http_header;
}
# Does CGI support logging?
# sub log_reason {}
# sub log_error {}
sub warn {
shift;
print STDERR @_, "\n";
}
sub params {
my $self = shift;
return HTML::Mason::Utils::cgi_request_args($self->query,
$self->query->request_method);
}
1;
__END__
=head1 NAME
HTML::Mason::FakeApache - An Apache object emulator for use with Mason
=head1 SYNOPSIS
See L<HTML::Mason::CGIHandler|HTML::Mason::CGIHandler>.
=head1 DESCRIPTION
This class's API is documented in L<HTML::Mason::CGIHandler|HTML::Mason::CGIHandler>.
=cut
( run in 0.846 second using v1.01-cache-2.11-cpan-39bf76dae61 )