NAME

Apache2::ASP::Response - Interact with the client.

SYNOPSIS

<%
  # Add a cookie:
  $Response->Cookies( cookiename => "cookie value" );
  
  # Add another HTTP header:
  $Response->AddHeader( 'x-micro-payment-required' => '0.001' );
  
  # Set the content-type header:
  $Response->{ContentType} = 'text/html';
  
  # Set the expiration date to 3 minutes ago:
  $Response->{Expires} = -3;
  
  # Print data to the client:
  $Response->Write("Welcome to the web page.<br>");
  
  # Include another file:
  $Response->Include(
    $Server->MapPath("/my-script.asp"),
    {arg => 'value'}
  );
  
  # Get the output from another file:
  my $result = $Response->TrapInclude(
    $Server->MapPath("/another-script.asp")
  );
  
  # Get a server variable:
  my $host = $Request->ServerVariables("HTTP_HOST");
  
  # Redirect:
  $Response->Redirect( "/new/page.asp" );
  
  # End processing and stop transmission:
  $Response->End;
  
  # Flush data to the client:
  $Response->Flush;
  
  # Clear the buffer:
  $Response->Clear();
  
  # Force auto-flush (no buffering):
  $Response->{Buffer} = 0;
  
  # Do something that takes a long time:
  while( not_done_yet() && $Response->IsClientConnected )
  {
    # do stuff...
  }# end while()
%>

DESCRIPTION

The global $Response object is an instance of Apache2::ASP::Response.

PUBLIC METHODS

AddHeader( $name, $value )

Adds a new header to the HTTP response

For example, the following:

<%
  $Response->AddHeader( "funny-factor" => "funny" );
%>

Sends the following in the HTTP response:

funny-factor: funny

Cookies( $name, $value )

Sends a cookie to the client.

Write( $str )

Writes data to the client. If buffering is enabled, the output will be deferred until Flush() is finally called (automatically or manually).

If buffering is disabled, the output will be sent immediately.

Flush( )

Causes the response buffer to be printed to the client immediately.

If the HTTP headers have not been sent, they are sent first before the response buffer is sent.

End( )

Stops processing and closes the connection to the client. The script will abort right after calling End().

Clear( )

Empties the response buffer. If Flush() has already been called, an exception is thrown instead.

Redirect( $url )

Causes the client to be redirected to $url.

If Flush() has already been called, an exception is thrown instead.

Include( $path, %args )

Executes the script located at $path and passes %args to the script. The result of the included script is included into the current response buffer.

The contents of %args are available to the included script as @_.

TrapInclude( $path )

Executes the ASP script located at $path and returns its results as a string.

IsClientConnected( )

Checks to see if the client is still connected. Returns 1 if connected, 0 if not.

AUTHOR

John Drago jdrago_999@yahoo.com

COPYRIGHT AND LICENSE

Copyright 2007 John Drago, All rights reserved.

This software is free software. It may be used and distributed under the same terms as Perl itself.