CC: | mike [...] nachbaur.com |
Subject: | Using ESI subinclude with absolute paths breaks |
If trying to do a subinclude with an absolute path, it seems to break, resulting in output that
looks like this:
<!--esi <esi:include src="/account/0/ARRAY(0xd28f950)" /> -->
The above example was taken from a page rendered at the URI "/account/profile", but I was
trying to do a subinclude of "/data/view/user?type=account_profile".
I've included a patch that does what I think needs to happen; namely it seems the current
implementation assumes the subinclude directive will load a relative URL from the current
location. If this isn't the case and my patch doesn't address all situations, what course of action
should be taken?
Thank you.
Subject: | SubInclude-ESI.patch |
--- /usr/local/share/perl/5.10.0/Catalyst/View/Component/SubInclude/ESI.pm 2009-12-08 10:57:36.000000000 -0500
+++ /home/nachbaur/tmp/new-ESI.pm 2009-12-08 10:57:33.000000000 -0500
@@ -59,12 +59,16 @@
my $args = ref $params[0] eq 'ARRAY' ? shift @params : [];
- my $dispatcher = $c->dispatcher;
- my ($action) = $dispatcher->_invoke_as_path( $c, $path, $args );
+ my $query_path = $path;
+ unless ($path =~ m#^/#) {
+ my $dispatcher = $c->dispatcher;
+ my ($action) = $dispatcher->_invoke_as_path( $c, $path, $args );
+
+ my $uri = $c->uri_for( $action, $args, @params );
+ $query_path = $uri->path_query;
+ }
- my $uri = $c->uri_for( $action, $args, @params );
-
- return '<!--esi <esi:include src="' . $uri->path_query . '" /> -->';
+ return '<!--esi <esi:include src="' . $query_path . '" /> -->';
}
=head1 SEE ALSO