Apache2-ASP

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

  - Apache2::ASP::Mock::RequestRec sometimes confess()ed if Response->Include was called.

2.15  2009-01-28
  - Made some minor tweaks to the way uploads are handled internally.  No public changes.

2.14  2009-01-25
  - <asp:Content/> tags inside of pages that use MasterPages were not being passed 
    TrapInclude or Include arguments (i.e. $Response->Include("/page.asp", { arg1 => "foo" }) ).

2.13  2009-01-25
  - Apache2::ASP::MediaManager did not provide any content-type header for
    file types not listed in MIME::Types (eg: *.ogv).  Now "application/octet-stream"
    is returned when MIME::Types does not return anything.

2.12  2009-01-20
  - The "Cookies" HTTP header was not properly handled in the Test UserAgent.
  - Incoming HTTP headers were comingled with outgoing HTTP headers in HTTPContext.

2.11  2009-01-10
  - Several fixes to cookie behavior problems.
  - Removed <module>Class::DBI::Lite</module> from apache2-asp-config.xml.

lib/Apache2/ASP/ErrorHandler.pm  view on Meta::CPAN

<div style="display: none;">
</body>
</html>
ERROR
  
  $Response->Write( $msg );
  $Server->Mail(
    To                          => $Config->errors->mail_errors_to,
    From                        => $Config->errors->mail_errors_from,
    Subject                     => "Apache2::ASP: Error in @{[ $ENV{HTTP_HOST} ]}@{[ $context->r->uri ]}",
    'content-type'              => 'text/html',
    'content-transfer-encoding' => 'base64',
    Message                     => encode_base64( $msg ),
    smtp                        => $Config->errors->smtp_server,
  );

}# end run()

1;# return true:

=pod

lib/Apache2/ASP/HTTPContext.pm  view on Meta::CPAN

    $s->{session} = $session_manager->new();
  }# end if()
  
  # Make the global Stash object:
  $s->{stash} = { };
    
  $s->{global_asa} = $s->resolve_global_asa_class( );
  {
    no warnings 'uninitialized';
    $s->{global_asa}->init_asp_objects( $s )
      unless $s->r->headers_in->{'content-type'} =~ m/multipart/;
  }
  
  $s->_load_class( $s->config->web->handler_resolver );
  eval {
    $s->{handler} = $s->config->web->handler_resolver->new()->resolve_request_handler( $s->r->uri );
  };
  if( $@ )
  {
    $s->server->{LastError} = $@;
    return $s->handle_error;

lib/Apache2/ASP/Manual/BestPractices.pod  view on Meta::CPAN

  
  # Create our base test object:
  my $s = __PACKAGE__->SUPER::new();
  
  # Make a request:
  my $res = $s->ua->get("/index.asp");
  
  # $res is a normal HTTP::Response object:
  ok( $res->is_success => "Got /index.asp" );
  like $res->content, qr/Hello, World/, "Contents look right";
  is( $res->header('content-type') => 'text/html' );

Run your tests with:

  prove t

All of your tests will be run.

=head1 CODE COVERAGE

Along with unit testing, code coverage is another great reason to use Apache2::ASP.

lib/Apache2/ASP/Mock/RequestRec.pm  view on Meta::CPAN

=head2 uri( [$new_uri] )

Read/Write.  Set or get the request URI.

=head2 method

Read-only.  Gets the request method - i.e. 'get' or 'post'.

=head2 content_type( [$new_content_type] )

Read/Write.  Set or get the B<outgoing> C<content-type> header.

=head2 connection

Read-only.  Returns the current L<Apache2::ASP::Mock::Connection> object.

=head1 PUBLIC METHODS

=head2 print( $string )

Adds C<$string> to the output buffer.

lib/Apache2/ASP/ModPerl.pm  view on Meta::CPAN

local $Apache2::ASP::HTTPContext::ClassName = 'Apache2::ASP::HTTPContext';


#==============================================================================
sub handler : method
{
  my ($class, $r) = @_;
  
  my $context = Apache2::ASP::HTTPContext->new();
  
  if( uc($r->method) eq 'POST' && $r->headers_in->{'content-type'} =~ m/multipart\/form\-data/ )
  {
    $context->{r} = $r;
    eval {
      $context->_load_class( $context->config->web->handler_resolver );
    };
    if( $@ )
    {
      warn $@;
      $r->status( 500 );
      return $r->status;

lib/Apache2/ASP/Response.pm  view on Meta::CPAN

  $Response->Flush;

=head1 DESCRIPTION

Apache2::ASP::Response offers a wrapper around the outgoing response to the client.

=head1 PUBLIC PROPERTIES

=head2 ContentType( [$type] )

Sets/gets the content-type response header (i.e. text/html, image/gif, etc).

Default: text/html

=head2 Status( [$status] )

Sets/gets the status response header (i.e. 200, 404, etc).

Default: 200

=head2 Expires( [$minutes] )

lib/Apache2/ASP/Server.pm  view on Meta::CPAN

  
  $s->context->config->web->www_root . $path;
}# end MapPath()


#==============================================================================
sub Mail
{
  my ($s, %args) = @_;
  
  # XXX: Base64-encode the content, and update the content-type to reflect that
  # if content-type === 'text/html'.
  # XXX: Consider updating this so that we can send attachments as well.
  Mail::Sendmail::sendmail( %args );
}# end Mail()


#==============================================================================
sub RegisterCleanup
{
  my ($s, $sub, @args) = @_;
  

lib/Apache2/ASP/Test/UserAgent.pm  view on Meta::CPAN

  
  chdir( $s->{cwd} );
  no strict 'refs';
  undef(${"$ContextClass\::instance"});
  {
    no warnings 'uninitialized';
    %ENV = ( DOCUMENT_ROOT => $ENV{DOCUMENT_ROOT} );
  }
  my $req = POST $uri, Content_Type => 'form-data', Content => $args;
  $ENV{REQUEST_METHOD} = 'POST';
  $ENV{CONTENT_TYPE} = $req->headers->{'content-type'};
  my $cgi = $s->_setup_cgi( $req );
  $ENV{CONTENT_TYPE} = 'multipart/form-data';
  
  my $r = Apache2::ASP::Mock::RequestRec->new();
  $r->uri( $uri );
  $r->args( $cgi->{querystring} );
  $r->{headers_in}->{Cookie} = $ENV{HTTP_COOKIE};
  
  $s->context->setup_request( $r, $cgi );
  

lib/Apache2/ASP/Test/UserAgent.pm  view on Meta::CPAN

  $ENV{HTTP_COOKIE} = join ';', @cookies;
  $ENV{DOCUMENT_ROOT} = $docroot
    if $docroot;
  
  if( $ENV{REQUEST_METHOD} =~ m/^post$/i )
  { 
    # Set up the basic params:
    return Apache2::ASP::SimpleCGI->new(
      querystring     => $ENV{QUERY_STRING},
      body            => $req->content,
      content_type    => $req->headers->{'content-type'},
      content_length  => $req->headers->{'content-length'},
    );
  }
  else
  {
    # Simple 'GET' request:
    return Apache2::ASP::SimpleCGI->new( querystring => $ENV{QUERY_STRING} );
  }# end if()
}# end _setup_cgi()

t/010-coverage/070-response.t  view on Meta::CPAN

#    $api->context->response->Status => 200
#  );
#}



# ContentType:
{
  local $api->context->{_did_send_headers};
  is( $api->context->response->ContentType => 'text/html' );
  ok( $api->context->response->ContentType('text/xhtml'), 'set content-type to text/xhtml' );
  is( $api->context->response->ContentType => 'text/xhtml' );
}



# Expires:
{
  local $api->context->{_did_send_headers};
  
  is( $api->context->response->Expires => 0, 'response.expires defaults to 0' );



( run in 2.438 seconds using v1.01-cache-2.11-cpan-524268b4103 )