package RSApache::Response::Direct;

use strict;
use warnings;

use Data::Dumper;

use Apache2::Const qw(OK);

use lib '/app/tools/common/lib';
use Common::WriteXML;
use Common::Assert;
use RSApache::Response::XML;

use RSApache::Response;
use base 'RSApache::Response';

use CGI;

use Data::Dumper;

sub _init {
    my ( $self, $fh, $type ) = @_;
    assert( defined $fh );

    $type = 'text/html' unless $type;

    $self->{fh}          = $fh;
    $self->{contentType} = $type;
}

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

    my $cgi = new CGI;
    $apache->content_type( $self->{contentType} );

    $apache->err_header_out( 'Pragma'        => 'no-cache' );
    $apache->err_header_out( 'Cache-control' => 'no-cache' );
    $apache->send_http_header();
    $apache->send_fd( $self->{fh} );
    close( $self->{fh} );

    return OK;
}

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

    # $apache->content_type("application/xml");
    $apache->content_type("text/xml");

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

    return OK;
}

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

