POE-Component-Server-SimpleHTTP

 view release on metacpan or  search on metacpan

lib/POE/Component/Server/SimpleHTTP/Response.pm  view on Meta::CPAN

package POE::Component::Server::SimpleHTTP::Response;
$POE::Component::Server::SimpleHTTP::Response::VERSION = '2.30';
#ABSTRACT: Emulates a HTTP::Response object, used for SimpleHTTP

use strict;
use warnings;

use base qw( HTTP::Response );

use Moose;
extends qw(HTTP::Response Moose::Object );

has '_WHEEL' => (
  is => 'rw',
);

has 'connection' => (
  is => 'ro',
  writer => 'set_connection',
);

has 'STREAM_SESSION' => (
  is => 'rw',
);

has 'STREAM' => (
  is => 'rw',
);

has 'STREAM_DONE' => (
  is => 'ro',
  default => sub { 0 },
  writer => 'set_stream_done',
  init_arg => undef,
);

has 'IS_STREAMING' => (
  is => 'ro',
  writer => 'set_streaming',
);

has 'DONT_FLUSH' => (
  is => 'rw',
  isa => 'Bool',
);

sub new {
   my $class = shift;

   # Get the Wheel ID
   my $wid = shift;

   # Get the Connection object
   my $conn = shift;

   # Make sure we got the wheel ID!
   if ( !defined $wid ) {
      die 'Did not get a Wheel ID!';
   }

   my $self = $class->SUPER::new(@_);

   return $class->meta->new_object(
          __INSTANCE__ => $self,
          _WHEEL => $wid,
	  connection => $conn,
    );
}

sub stream {
   my $self = shift;
   my %opt = (@_);

   no strict 'refs';

   if ( $opt{event} ne '' ) {
      $self->STREAM_SESSION( $opt{'session'} || undef );
      $self->STREAM( $opt{'event'} );
      $self->DONT_FLUSH( $opt{'dont_flush'} );
   }
   else {
      $self->STREAM( shift );
   }
}

no Moose;

__PACKAGE__->meta->make_immutable( inline_constructor => 0 );

# End of module
1;

__END__

=pod

=encoding UTF-8

=head1 NAME



( run in 0.826 second using v1.01-cache-2.11-cpan-140bd7fdf52 )