Hi All,
Just helping out with a little triage and came to this bug:
http://mongrel2.org/tktview?name=ea23f3f8e0
The complaint is basically that setting "default_host" on a server
doesn't work as expected. Specifically, the default host will be used
if no host is specified at all in the request, but not if the request
specifies a host that doesn't exist in the settings db.
Is this the intended behaviour of the default_host setting, or should
it also be used as a generic fallback for hosts that don't exist?
Ryan
--
Ryan Kelly
http://www.rfk.id.au | This message is digitally signed. Please visit
ryan@rfk.id.au | http://www.rfk.id.au/ramblings/gpg/ for details
Hello, > Just helping out with a little triage and came to this bug: > > http://mongrel2.org/tktview?name=ea23f3f8e0 > > > The complaint is basically that setting "default_host" on a server > doesn't work as expected. Specifically, the default host will be used > if no host is specified at all in the request, but not if the request > specifies a host that doesn't exist in the settings db. > > Is this the intended behaviour of the default_host setting, or should > it also be used as a generic fallback for hosts that don't exist? If it helps, a discussion related to this setting is here: http://librelist.com/browser//mongrel2/2010/12/30/cannot-do-a-catch-all-on-host-match/#516858aa332e9c0ee524412ee02fdd49 // Copy/paste from Zed's answer: 1. Request comes in for a host to the port. 2. Server listening on that port runs the Host.name against the routing list. 3. If it finds a match (by name), it uses that Host. 4. If not, it uses the host set in Server.default_host. I think the confusion is the existence of Host.name and Host.matching, so probably need a ticket for making one of those not exist or clarifying it. // end of paste. If I understood correctly Mongrel2 is at the moment "strict", that is, you need to match to be served. But at the same time, from the worflow highlighted by Zed, it should trigger the default_host if no match and a default. Is it because you have only one host and the host is the default too? loïc
On Mon, 2011-02-14 at 14:06 +0100, Loic d'Anterroches wrote: > > If it helps, a discussion related to this setting is here: > http://librelist.com/browser//mongrel2/2010/12/30/cannot-do-a-catch-all-on-host-match/#516858aa332e9c0ee524412ee02fdd49 > > // Copy/paste from Zed's answer: > > 1. Request comes in for a host to the port. > 2. Server listening on that port runs the Host.name against the routing > list. > 3. If it finds a match (by name), it uses that Host. > 4. If not, it uses the host set in Server.default_host. > > I think the confusion is the existence of Host.name and Host.matching, > so probably need a ticket for making one of those not exist or > clarifying it. > > // end of paste. > > > If I understood correctly Mongrel2 is at the moment "strict", that is, > you need to match to be served. But at the same time, from the worflow > highlighted by Zed, it should trigger the default_host if no match and a > default. Ah OK, default_host is used as a pattern match. From the Server_match_backend function: Route *found = RouteMap_match_suffix(srv->hosts, target); if(found) { return found->data; } else { if(bstring_match(target, srv->default_hostname)) { return srv->default_host; } else { return NULL; } } So for it to work as a catch-all you need to use a match-all pattern. I guess the original bug can safely be marked not-a-bug then. Out of curiosity, what sort of use-cases are there for having a default host that's not a catch-all? Thanks for the clarification, Ryan -- Ryan Kelly http://www.rfk.id.au | This message is digitally signed. Please visit ryan@rfk.id.au | http://www.rfk.id.au/ramblings/gpg/ for details