NAME

OpenInteract2::Response - Information about and actions on an HTTP response

SYNOPSIS

 # Normal usage
 
 use HTTP::Status qw( RC_OK );
 
 my $response = CTX->response;
 $response->status( RC_OK );                 # default
 $response->content_type( 'text/html' )      # default
 $response->header( 'X-Powered-By' => 'OpenInteract 2.0' );
 my $cookie = CTX->cookie->create({ name    => 'session',
                                    expires => '+3d',
                                    value   => 'ISDFUASDFHSDAFUE' });
 $response->cookie( 'session', $cookie );
 
 # Sends the header (including cookies) and content to client
 
 $response->send;

DESCRIPTION

METHODS

Class Methods

set_implementation_type( $type )

get_implementation_type()

new()

Object Methods

content_type( [ $content_type ] )

Get/set the content type. This will be used in the header.

content_type_header

Retrieve a content type usable for the header. This includes the charset if it has been set.

header( [ $name, $value ] )

If both arguments passed in, set the header $name to $value.

If only $name, return its header value.

If neither, pass a hashref with all set headers.

remove_header( $name )

Deletes the header $name from the response.

is_redirect

Returns true is the status has been set to be a redirect, false if not.

cookie( [ $cookie ] )

remove_cookie( $name )

send()

redirect()

Methods for Subclasses

set_file_info()

init()

PROPERTIES

All of the properties can be get and set by their name. For example:

 my $status = $response->status;          # Get the current status
 $response->status( RC_MAN_OVERBOARD );   # Set a new status

status - HTTP status of this response. If not set it will be set to RC_OK (from HTTP::Status) in the controller.

controller - The controller assigned to this response. This is useful for modifying the default template layout, setting the page title, etc. See OpenInteract2::Controller for more information.

return_url - A URL to which the user should return. This is useful for login boxes or other links that you don't want pointing to a particular place without first going through the correct path. For instance, returning from a '/Foo/edit/' you may want to set the return URL to '/Foo/show/' or something else harmless so you don't accidentally submit a new 'edit'. (Redirects are good for this, too.)

When you set a return URL the response object ensures the given URL is located under the server context; therefore, the value returned from this property is always located under the server context.

send_file - Filename of file to send directly to the user. It is generally a good idea to set the 'Content-Type' header (via add_header()) when doing this.

content - Set the content for this response. Can be a scalar or a reference to a scalar, so the following will wind up displaying the same information:

 my $foo = "Fourscore and seven years ago...";
 $response->content( $foo );
 $response->content( \$foo );

charset - Set the character set for this response. If unset we do not pass it along with the content type.

SUBCLASSING

The actual work to send the correct data to the client is accomplished by a subclass of this class. Subclasses must do the following:

SEE ALSO

Class::Factory

OpenInteract2::Response::Apache

OpenInteract2::Response::CGI

OpenInteract2::Response::LWP

OpenInteract2::Response::Standalone

COPYRIGHT

Copyright (c) 2002-2005 Chris Winters. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

AUTHORS

Chris Winters <chris@cwinters.com>

Generated from the OpenInteract 1.99_06 source.