Skip Menu |

This queue is for tickets about the Maypole CPAN distribution.

Report information
The Basics
Id: 14135
Status: open
Priority: 0/
Queue: Maypole

People
Owner: TEEJAY [...] cpan.org
Requestors: dave [...] riverside-cms.co.uk
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: send_output should return a status code
The send_output methods in the frontend classes should return a status code, and Maypole::handler() should return that code, rather than assuming that the code has not changed from OK during send_output().
[DAVEBAIRD - Fri Aug 12 06:46:22 2005]: Show quoted text
> The send_output methods in the frontend classes should return a status > code, and Maypole::handler() should return that code, rather than > assuming that the code has not changed from OK during send_output().
Can we have a bit more detail of which module send_output is in, etc? If the solution is obvious can you apply a fix in SVN otherwise suggest a general plan here or on the list Thanks, A.
[TEEJAY - Mon Aug 22 14:19:54 2005]: Show quoted text
> [DAVEBAIRD - Fri Aug 12 06:46:22 2005]: >
> > The send_output methods in the frontend classes should return a
> status
> > code, and Maypole::handler() should return that code, rather than > > assuming that the code has not changed from OK during send_output().
> > > Can we have a bit more detail of which module send_output is in, etc?
Maypole::handler() finishes like this: my $status = $r->handler_guts(); return $status unless $status == OK; $r->send_output; return $status; send_output is defined in the particular frontend - CGI::Maypole, Apache::MVC, MasonX::Maypole, Maypole::CLI. The first 2 print their output, but don't check for an error from the print method, and implicitly return the return value of the print call. These send_output methods are pretty straightforward and there's not much opportunity for an error, but if there is one, it will not be caught. MasonX::Maypole::send_output has to jump through a few more hoops, so is more error prone. Also, templates run perl code, which is run during send_output, so there's plenty of scope for errors. The final call is to the Mason exec() method, which returns a HTTP status code i.e. SERVER_ERROR if there's a syntax error in one of the templates. The expectation is that the status code will be returned to the handler, which will return it to the client. But the handler ignores it. Show quoted text
> If the solution is obvious can you apply a fix in SVN otherwise > suggest > a general plan here or on the list
The solution I think is that the frontends that don't want or need to check for errors in send_output should return OK. Maypole::handler should then return the rv from the send_output call: my $status = $r->handler_guts(); return $status unless $status == OK; return $r->send_output; If that looks reasonable I can fix up the frontends. d.
[guest - Mon Aug 22 18:30:39 2005]: Show quoted text
> [TEEJAY - Mon Aug 22 14:19:54 2005]: >
> > [DAVEBAIRD - Fri Aug 12 06:46:22 2005]: > >
> > > The send_output methods in the frontend classes should return a
> > status
> > > code, and Maypole::handler() should return that code, rather than > > > assuming that the code has not changed from OK during
> send_output().
> > > > > > Can we have a bit more detail of which module send_output is in,
> etc? > > Maypole::handler() finishes like this: > > my $status = $r->handler_guts(); > return $status unless $status == OK; > $r->send_output; > return $status; > > send_output is defined in the particular frontend - CGI::Maypole, > Apache::MVC, MasonX::Maypole, Maypole::CLI. The first 2 print their > output, but don't check for an error from the print method, and > implicitly return the return value of the print call. These > send_output > methods are pretty straightforward and there's not much opportunity > for > an error, but if there is one, it will not be caught. > > MasonX::Maypole::send_output has to jump through a few more hoops, so > is > more error prone. Also, templates run perl code, which is run during > send_output, so there's plenty of scope for errors. The final call is > to > the Mason exec() method, which returns a HTTP status code i.e. > SERVER_ERROR if there's a syntax error in one of the templates. The > expectation is that the status code will be returned to the handler, > which will return it to the client. But the handler ignores it. > >
> > If the solution is obvious can you apply a fix in SVN otherwise > > suggest > > a general plan here or on the list
> > The solution I think is that the frontends that don't want or need to > check for errors in send_output should return OK. Maypole::handler > should then return the rv from the send_output call: > > my $status = $r->handler_guts(); > return $status unless $status == OK; > return $r->send_output; > > If that looks reasonable I can fix up the frontends. > > d.
Let's tag this for 2.12. Although the fix is easy enough, we should look at this together with the workflow changes. d.
HTTP Status codes are now returned by the handler, does this overcome the problem?