package RSApache::Response;

use strict;
use warnings;
use Apache2::Const;
use Data::Dumper;

# This is the base class for all our Response objects.
# It's abstract: We'll provide the constructor here,
# but leave it to the dervied classes to implement
# the 'virtual' methods (which we'll document here).
#

sub new {
    my ( $class, @params ) = @_;

    my $self = bless {}, $class;

    $self->_init(@params);

    return $self;
}

#
# _init - VIRTUAL METHOD
#
# - Initialization routine.
#
sub _init {
    my ( $self, @args ) = @_;
}

#
# respond - PURE VIRTUAL METHOD
#
# - Implements this object's response behavior
#   Subclasses override this to do whatever they do...
#
#   Takes a reference to an Apache object.
#   Returns the correct Apache response code.
#
#   This is 'pure' virtual - not going to provide a default
#   behavior... The following commented-out code can be used
#   as a template.
#
#sub respond
#{
#	my ($self, $apache) = @_;
#   my $returnCode = APACHE::OK;
#
#   return $returnCode;
#}

#
# respondRaw - VIRTUAL METHOD
#
# - Implements this object's debugging response behavior.
#   If you pass 'raw=1' as a cgi parameter, the handler is going
#   to call this method, rather than the usual respond method.
#
#   Reponse classes should therefore do whatever seems reasonable
#   (which generally means spewing forth their state as plain text.)
#   The default behavior is just to print out the object via Dumper.
#

sub respondRaw {
    my ( $self, $apache ) = @_;

    $apache->content_type("text/plain");
    $apache->send_http_header();

    print Dumper($self) . "\n";

    return OK;
}

###
1;    # Play nicely.
###
