ASP4
view release on metacpan or search on metacpan
2012-02-02 1.078
- Fixed installation problem that came up in v1.075
(compilation root was missing leading forward slash on non-windows systems).
2012-02-01 1.077
- Loath to add a mime-types-all-knowing dependency, we have a small list of
common mime-types (html, css, js, etc).
- Added mime for html and svg.
2012-02-01 1.076
- Now, the 'content-type' header is set correctly for ASP4::UserAgent responses.
- Works correctly under ASP4::PSGI (images, css, javascript all show up).
2012-02-01 1.075
- Now, works on Windows!
- eric.hayes++
2012-01-30 1.074
- Explicit calls to $Session->save() are no longer necessary.
2012-01-23 1.073
README.markdown view on Meta::CPAN
message => 'this is a test message'
);
To send an HTML email do the following:
use MIME::Base64;
$Server->Mail(
from => 'foo@bar.com',
to => 'bar@foo.com',
subject => 'Hello, world!',
'content-type' => 'text/html',
'content-transfer-encoding' => 'base64',
message => encode_base64(<<"HTML")
<html>
<body>
<p>This is an html email.</p>
<p>You can see that <b>this text is bold</b>.</p>
</body>
</html>
HTML
);
lib/ASP4.pm view on Meta::CPAN
message => 'this is a test message'
);
To send an HTML email do the following:
use MIME::Base64;
$Server->Mail(
from => 'foo@bar.com',
to => 'bar@foo.com',
subject => 'Hello, world!',
'content-type' => 'text/html',
'content-transfer-encoding' => 'base64',
message => encode_base64(<<"HTML")
<html>
<body>
<p>This is an html email.</p>
<p>You can see that <b>this text is bold</b>.</p>
</body>
</html>
HTML
);
lib/ASP4/ErrorHandler.pm view on Meta::CPAN
sub send_error
{
my ($s, $error) = @_;
$Server->Mail(
To => $Config->errors->mail_errors_to,
From => $Config->errors->mail_errors_from,
Subject => "ASP4: Error in @{[ $ENV{HTTP_HOST} ]}@{[ $ENV{REQUEST_URI} ]}",
'content-type' => 'text/html',
'content-transfer-encoding' => 'base64',
Message => encode_base64( $s->error_html($error) ),
smtp => $Config->errors->smtp_server,
);
}# end send_error()
sub error_html
{
my ($s, $error) = @_;
lib/ASP4/FileUpload.pm view on Meta::CPAN
=head2 FileSize
The size of the uploaded file in bytes.
=head2 FileHandle
Returns a filehandle (open for reading) pointing to the uploaded file.
=head2 ContentType
The C<content-type> header supplied by the browser for the uploaded file.
=head2 FileContents
The contents of the uploaded file.
=head1 PUBLIC METHODS
=head2 SaveAs( $path )
Writes the contents of the uploaded file to C<$path>. Will throw an exception if
lib/ASP4/Mock/RequestRec.pm view on Meta::CPAN
sub err_headers_out { shift->{err_headers_out} }
sub buffer { shift->{buffer} } # Not documented:
# Public methods:
sub print { my ($s,$str) = @_; $s->{buffer} .= $str; }
sub content_type
{
my ($s, $type) = @_;
return $s->headers_out->{'content-type'} unless $type;
$s->headers_out->{'content-type'} = $type;
}# end content_type()
sub rflush { }
1;# return true:
=pod
=head1 NAME
lib/ASP4/ModPerl.pm view on Meta::CPAN
{
my ($class, $r) = @_;
$ENV{DOCUMENT_ROOT} = $r->document_root;
$ENV{REMOTE_ADDR} = $r->connection->get_remote_host();
$ENV{HTTP_HOST} = $r->hostname;
my $context = ASP4::HTTPContext->new();
$r->pool->cleanup_register(sub { $context->DESTROY });
if( ($r->headers_in->{'content-type'}||'') =~ m/multipart\/form\-data/ )
{
$context->{r} = $r;
if( $@ )
{
warn $@;
$r->status( 500 );
return $r->status;
}# end if()
my $handler_class = eval {
lib/ASP4/Response.pm view on Meta::CPAN
sub ContentType
{
my $s = shift;
if( @_ )
{
my $type = shift;
$s->{_content_type} = $type;
$s->context->r->content_type( $type );
$s->SetHeader( 'content-type' => $type );
}
else
{
return $s->{_content_type};
}# end if()
}# end ContentType()
sub Expires
{
lib/ASP4/Response.pm view on Meta::CPAN
sub End
{
my $s = shift;
if( $s->Status =~ m{^2} )
{
$s->Flush;
}
else
{
delete $s->context->headers_out->{'content-type'};
}# end if()
# Would be nice to somehow stop all execution:
$s->context->did_end( 1 );
}# end End()
sub Flush
{
my $s = shift;
lib/ASP4/Response.pm view on Meta::CPAN
my $expires_on = $Response->ExpiresAbsolute;
=head1 DESCRIPTION
The C<$Response> object offers a unified interface to send content back to the client.
=head1 PROPERTIES
=head2 ContentType( [$type] )
Sets or gets the C<content-type> header for the response. Examples are C<text/html>, C<image/gif>, C<text/csv>, etc.
=head2 Status( [$status] )
Sets or gets the C<Status> header for the response. See L<http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html> for details.
B<NOTE:> Only the numeric part is necessary - eg: 200, 301, 404, etc.
=head2 Headers()
Returns the L<HTTP::Headers> object that will be used for the outgoing response.
lib/ASP4/UserAgent.pm view on Meta::CPAN
# Cookies:
$req->header( 'Cookie' => $ENV{HTTP_COOKIE} = $s->http_cookie );
if( $ENV{REQUEST_METHOD} =~ m/^post$/i )
{
# Set up the basic params:
return ASP4::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 ASP4::SimpleCGI->new( querystring => $ENV{QUERY_STRING} );
}# end if()
}# end _setup_cgi()
t/010-basic/090-everything.t view on Meta::CPAN
use ASP4::API;
my $api = ASP4::API->new;
ok( my $res = $api->ua->get('/everything/step01.asp'), "Got res");
ok(
$res = $api->ua->get('/handlers/dev.headers'), "Got headers res again"
);
is(
$res->header('content-type') => 'text/x-test'
);
is(
$res->header('content-length') => 3000
);
is(
$res->content => "X"x3000
);
# static:
{
( run in 1.524 second using v1.01-cache-2.11-cpan-0c5ce583b80 )