Daemon send_response

Cliff Wheatley (cwheat@concordia.net)
Thu, 15 Jul 1999 20:53:25 -0400 (EDT)


=A0 Is it appropriate for the send_response method to assume that=20
the $res parameter is an HTTP::Response object?=A0 The documentation=20
says that you can pass a code reference to send chunked messages.=A0
But the line marked below calls the content method of the Response
object.=A0 If I pass a code reference instead of Response object=20
(like the documentation says I can) then this line will fail.

From=20the Daemon.pm module:

sub send_response
{
=A0=A0=A0 my $self =3D shift;
=A0=A0=A0 my $res =3D shift;
=A0=A0=A0 if (!ref $res) {
$res ||=3D RC_OK;
$res =3D HTTP::Response->new($res, @_);
=A0=A0=A0 }
=A0=A0=A0 my $content =3D $res->content;=A0=A0=A0=A0=A0=A0 ##=A0=A0 <-- Fai=
ls here when passing a
code ref
=2E . .
=A0=A0=A0 if (ref($content) eq "CODE") {=A0=A0 ##=A0=A0 <-- code ref will n=
ever get to
here

Shouldn't the test for a code ref happen prior to calling the content
method?=A0 Or am I misusing this object.

>> my script fragment >>
$sub =3D sub { my $answer =3D [ "some strings", "more strings", "etc" ];
$$answer[$count++]; };
$c->send_response($sub);

--
-Cliff
Views expressed are my own and not necessarily those of my employer
Concordia Net, Inc.