ASP4
view release on metacpan or search on metacpan
lib/ASP4/Response.pm view on Meta::CPAN
$Response->SetHeader( 'x-velocity' => '100MPH' );
# Expires in the future:
$Response->Expires( '30M' ); # 30 minutes from now
$Response->Expires( '30H' ); # 30 hours from now
$Response->Expires( '30D' ); # 30 days from now
# Expires in the past:
$Response->Expires( '-30M' ); # 30 minutes ago
$Response->Expires( '-30H' ); # 30 hours ago
$Response->Expires( '-30D' ); # 30 days ago
$Response->SetCookie(
# Required parameters:
name => "customer-email",
value => $Form->{email},
# The rest are optional:
expires => '30D', # 30 days
path => '/',
domain => '.mysite.com',
);
$Response->Redirect( "/path/to/page.asp" );
$Response->Include( $Server->MapPath("/my/include.asp") );
$Response->Include( $Server->MapPath("/my/include.asp"), \%args );
my $string = $Response->TrapInclude( $Server->MapPath("/my/widget.asp") );
my $string = $Response->TrapInclude( $Server->MapPath("/my/widget.asp"), \%args );
return $Response->Declined;
$Response->End;
while( 1 ) {
last unless $Response->IsClientConnected();
$Response->Write("Still Here!<br/>");
sleep(1);
}
my HTTP::Headers $headers = $Response->Headers;
# Read-only:
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.
If necessary, you can manipulate this object in any way you see fit.
=head2 Declined
For use within a L<ASP4::RequestFilter> subclass, like this:
sub run {
# Permit requests only every other second:
if( time() % 2 ) {
return $Response->Declined;
}
else {
$Response->Write("Try again");
return $Response->End;
}
}
=head2 IsClientConnected
In a ModPerl environment, this can be used to determine whether the client has
closed the connection (hit the "Stop" button or closed their browser). Useful within
a long-running loop.
=head1 METHODS
=head2 Write( $str )
Adds C<$str> to the output buffer.
=head2 Flush( )
Causes the output buffer to be flushed to the client.
=head2 End( )
Aborts the current request.
Example:
# Good:
return $Response->End;
Simply calling...
# Bad!
$Response->End;
...will not work as intended.
=head2 AddHeader( $name => $value )
Appends C<$value> to the header C<$name>.
=head2 SetHeader( $name => $value )
( run in 0.533 second using v1.01-cache-2.11-cpan-39bf76dae61 )