Is it an Internal Server Error if no component is able to produce the 
page or should Mason pass this on to Apache so that Apache can produce a 
404 page?

My opinion is that it should pass it on to Apache. This has the benefit of 
a single dhandler/component not having to know if there's a dhandler above 
it (should use $m->decline;) or not (should use $m->abort(404);). It could 
just decline in both cases.

The documentation appears to agree with me:
http://www.masonhq.com/docs/manual/Request.html#item_decline
"If no dhandler is available, a not-found error occurs."

..so is this a bug?


Let's say I have an empty site with only /dhandler and just one line in 
it:

% $m->decline;

Now if a non-existing page is accessed (like /foo/bar.html) the dhandler 
picks up and then declines. This now causes an 500 Internal Server Error 
response and "[error] could not find component for initial path 
'/foo/bar.html'" entry to error log in fatal error mode.

The same occurs if there's a component /decliner.mpl with the same 
$m->decline line and that component is accessed.

I'm referring to Task #573,
        http://www.masonhq.com/resources/todo/view.html?id=573

There's a slight difference in the if structure of the 1.27 patch and the 
way it was implemented in 1.29_01. The way the patched 1.27 handles the 
case is to pass it on to Apache.

This is in the Request Class.

## Mason 1.35:
# If the component was declined previously in this
# request, look for the next dhandler up the
# tree.
if ($request_comp and $self->{declined_comps}->{$request_comp->comp_id}) {
     $path = $request_comp->dir_path;
     if ($request_comp->name eq $self->dhandler_name) {
         if ($path eq '/') {
             undef $request_comp;
             last search;  # End search if /dhandler declined
         } else {
             $path =~ s:/[^\/]+$::;
             $path ||= '/';
         }
     }
     if ($retry_count++ > $self->max_recurse) {
         error "could not find dhandler after " .
        $self->max_recurse . " tries (infinite loop bug?)";
     }
     redo search;
}


## Mason 1.27 with the patch:
# If the component was declined previously in this request,
# look for the next dhandler up the tree.
if ($request_comp and $self->{declined_comps}->{$request_comp->comp_id}) {
     $path = $request_comp->dir_path;
     if ($path eq '/' and $request_comp->name eq $self->dhandler_name) {
         undef $request_comp;
     } else {
         if ($request_comp->name eq $self->dhandler_name) {
             $path =~ s:/[^\/]+$::;
             $path ||= '/';
         }
         redo search;
     }
}



------------------------------------------------------------------------
Oskari "Okko" Ojala
Frantic Media

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Mason-users mailing list
Mason-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mason-users

Reply via email to