Date: Monday January 20, 2003 @ 16:19
Author: matt
Update of /home/cvs/AxKit-XSP-Util
In directory ted.sergeant.org:/home/matt/Perl/AxKit-XSP-Util
Modified Files:
Makefile.PL Util.pm
Log Message:
Allow relative URIs
Remove use of HTTP::GHTTP
Log:
PR:
Index: Makefile.PL
===================================================================
RCS file: /home/cvs/AxKit-XSP-Util/Makefile.PL,v
retrieving revision 1.4
retrieving revision 1.5
diff -b -u -r1.4 -r1.5
--- Makefile.PL 2002/01/30 09:38:42 1.4
+++ Makefile.PL 2003/01/20 16:19:32 1.5
@@ -6,9 +6,9 @@
'VERSION_FROM' => 'Util.pm', # finds $VERSION
'PREREQ_PM' => {
AxKit => 1.5,
- HTTP::GHTTP => 1.0,
Time::Piece => 1.0,
Apache::File => 0,
XML::LibXML => 1.31,
+ URI => 1.0,
},
);
Index: Util.pm
===================================================================
RCS file: /home/cvs/AxKit-XSP-Util/Util.pm,v
retrieving revision 1.16
retrieving revision 1.17
diff -b -u -r1.16 -r1.17
--- Util.pm 2002/09/13 11:29:12 1.16
+++ Util.pm 2003/01/20 16:19:32 1.17
@@ -1,9 +1,9 @@
-# $Id: Util.pm,v 1.16 2002/09/13 11:29:12 jwalt Exp $
+# $Id: Util.pm,v 1.17 2003/01/20 16:19:32 matt Exp $
package AxKit::XSP::Util;
use strict;
use Apache::AxKit::Language::XSP;
-use HTTP::GHTTP;
+use URI::WithBase;
use Apache::File;
use XML::LibXML 1.31;
use Time::Piece; # overrides localtime
@@ -13,7 +13,7 @@
@ISA = ('Apache::AxKit::Language::XSP');
$NS = 'http://apache.org/xsp/util/v1';
-$VERSION = "1.6";
+$VERSION = "1.7";
## Taglib subs
@@ -27,7 +27,7 @@
$parent->appendChild($root);
}
else {
- die "XML::LibXML returned undef";
+ die "Couldn't load or parse file: $filename";
}
}
@@ -40,23 +40,25 @@
sub include_uri {
my ($document, $parent, $uri) = @_;
- my $raw_xml;
+ my $doc;
if ($uri =~ /^axkit:/) {
- $raw_xml = AxKit::get_axkit_uri($uri);
+ my $raw_xml = AxKit::get_axkit_uri($uri);
+ $doc = XML::LibXML->new->parse_string($raw_xml);
}
else {
- my $ua = HTTP::GHTTP->new($uri);
- $ua->process_request;
- $raw_xml = $ua->get_body;
+ my $r = Apache->request;
+ my $base = "http://" . $r->hostname . ":" . $r->server->port . $r->uri;
+ $uri = URI::WithBase->new($uri, $base)->abs();
+ # LibXML supports remote URIs
+ $doc = XML::LibXML->new->parse_file($uri);
}
- my $doc = XML::LibXML->new()->parse_string($raw_xml);
if ($doc) {
my $root = $doc->getDocumentElement();
$root = $document->importNode($root);
$parent->appendChild($root);
}
else {
- die "XML::LibXML returned undef";
+ die "Couldn't load or parse document at $uri";
}
}
@@ -71,7 +73,7 @@
$parent->appendChild($root);
}
else {
- die "XML::LibXML returned undef";
+ die "Couldn't load or parse expression results";
}
}
}
@@ -289,7 +291,11 @@
=head2 C<<util:include-uri>>
Provides a way to include an XML fragment from a (possibly) remote URI.
-Requires an B<href> argument.
+Requires an B<href> argument. If the URI is relative, it tries to do the
+right thing using the current URI as base.
+
+Also note that you can include URIs starting with axkit: and this will
+do an internal request.
=head2 C<<util:get-file-contents>>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]