POE-Component-FastCGI

 view release on metacpan or  search on metacpan

lib/POE/Component/FastCGI.pm  view on Meta::CPAN

   }else{

     if(ref($run->[1]) eq 'CODE' or $run->[1]->isa('POE::Session::AnonEvent') ) {
       $run->[1]->($request, $run->[0]);
     } else {
       $kernel->post($heap->{Session}, $run->[1],$request, $run->[0]);
     }

	 if($request->{_res}) {
		 # Streaming support
		 if($request->{_res}->streaming) {
			 push @{$heap->{toclose}->{$wheel_id}}, $request->{_res};
		 } else {
			 # Send and break circular ref
			 $request->{_res}->send if exists $request->{_res}->{client};
			 $request->{_res} = 0;
		 }
	 }
   }
}

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

   $response->{requestid} = $id;

   return $response;
}

sub DESTROY {
   my($self) = @_;
   $self->close;
}

sub streaming {
   my($self, $streaming) = @_;
   if(defined $streaming) {
      $self->{streaming} = $streaming;
   }else{
      return $self->{streaming};
   }
}

sub closed {
   my($self, $callback) = @_;
   if(defined $callback) {
      $self->{closed} = $callback;
   }elsif(defined $self->{closed}) {
      $self->{closed}->($self);
   }

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

Therefore the following methods mostly deal with actually sending the
response:

=over 4

=item $response = POE::Component::FastCGI::Response->new($client, $id, $code)

Creates a new C<POE::Component::FastCGI::Response> object, parameters from
C<$code> onwards are passed directly to L<HTTP::Response>'s constructor.

=item $response->streaming

Set and check streaming status

=item $response->closed

Set a callback to be called when this response is closed, mainly useful for
streaming.

=item $response->send

Sends the response object and ends the current connection.

=item $response->write($text)

Writes some text directly to the output stream, for use when you don't want
to or can't send a L<HTTP::Response> object.

lib/POE/Component/FastCGI/Stream.pm  view on Meta::CPAN

				my $session = $poe_kernel->alias_resolve("client-$id");
				if(not defined $session) {
					$request->make_response->code(404);
					return;
				}

				return unless check_cookie($session->get_heap, $request);

				$param = "default" unless defined $param and $param;

				# If this wants to set streaming post won't do
				$poe_kernel->call($session => "in_$param", $request);

				if(not defined $request->{_res}) {
					$request->make_response->code(404);
				}
			} ],
			[ "$prefix/new" => sub {
				my($request) = @_;

				my $type = $request->query("type");

lib/POE/Component/FastCGI/Stream.pm  view on Meta::CPAN


sub stream {
	my($heap, $request) = @_[HEAP, ARG0];

	return unless check_cookie($heap, $request);

	delete $heap->{stream} if exists $heap->{stream};

	my $response = $request->make_response;
	$response->write("Content-type: text/html\r\n\r\n");
	$response->streaming(1);
	$response->closed(\&stream_closed);
	$response->{id} = $heap->{sessid};

	if($heap->{type} eq 'iframe') {
		$response->write("<html>\nstream $request->{requestid}\n<!-- "
			. ("padding " x 10) . "-->\n\n");
	}
	$heap->{stream} = $response;
	$response->write(wrap_output($heap, delete $heap->{buffer}));
}



( run in 0.253 second using v1.01-cache-2.11-cpan-4d50c553e7e )