ASP4

 view release on metacpan or  search on metacpan

lib/ASP4/Mock/RequestRec.pm  view on Meta::CPAN


package ASP4::Mock::RequestRec;

use strict;
use warnings 'all';
use ASP4::Mock::Pool;
use ASP4::Mock::Connection;
use ASP4::ConfigLoader;
use Scalar::Util 'weaken';


sub new
{
  my ($class, %args) = @_;
  
  my $s = bless {
    status        => 200,
    content_type  => 'text/plain',
    buffer        => '',
    document_root => ASP4::ConfigLoader->load()->web->www_root,
    headers_in    => { },
    headers_out   => { },
    uri           => $args{uri} || $ENV{REQUEST_URI},
    args          => $args{args} || $ENV{QUERY_STRING},
    pnotes        => { },
    method        => $args{method},
    pool          => ASP4::Mock::Pool->new(),
    connection    => ASP4::Mock::Connection->new(),
  }, $class;
  
  weaken($s->{connection});
  $s->{err_headers_out} = $s->{headers_out};
  $s->{filename}        = $s->document_root . $s->uri;
  
  return $s;
}# end new()


# Public read-write properties:
sub pnotes
{
  my $s = shift;
  my $name = shift;
   @_ ? $s->{pnotes}->{$name} = shift : $s->{pnotes}->{$name};
}# end pnotes()

sub uri
{
  my $s = shift;
  @_ ? $s->{uri} = shift : $s->{uri};
}# end uri()

sub args
{
  my $s = shift;
  @_ ? $s->{args} = shift : $s->{args};
}# end args()

sub status {
  my $s = shift;
  @_ ? $s->{status} = +shift : $s->{status};
}# end status()


# Public read-only properties:
sub document_root   { shift->{document_root} }
sub method          { uc( shift->{method} ) }
sub pool            { shift->{pool} }
sub connection      { shift->{connection} }
sub headers_out     { shift->{headers_out} }
sub headers_in      { shift->{headers_in} }
sub err_headers_out { shift->{err_headers_out} }

sub buffer          { shift->{buffer} } # Not documented:




( run in 1.595 second using v1.01-cache-2.11-cpan-39bf76dae61 )