On Mon, 2 Oct 2000, Ken Williams wrote:
> In looking over the changes, I found that I've done a little more work
> since the last patch I sent. I didn't send it on because I wasn't sure
> whether the first patch would be accepted or not. Anyway, I beefed up
> the fetch() method and documented it. It's fully backward compatible,
> so no changes are necessary to existing code that calls fetch(). I also
> added/fixed tiny pieces in my previous work here and there.
thanks ken, i applied this patch, but it broke modules/cgi 3-4,7, because
it calls fetch() in an array context. i applied the bandaid below to get
by for now. maybe it would be better for your more robust version of
fetch() to be called get(), and the old fetch() becomes a wrapper around
that?
Index: lib/Apache/test.pm
===================================================================
RCS file: /home/cvs/modperl/lib/Apache/test.pm,v
retrieving revision 1.18
diff -u -r1.18 test.pm
--- lib/Apache/test.pm 2000/10/02 20:25:13 1.18
+++ lib/Apache/test.pm 2000/10/02 21:05:29
@@ -210,7 +210,8 @@
sub fetch {
# Old code calls fetch() as a function, new code as a method
- shift() if UNIVERSAL::isa($_[0], __PACKAGE__);
+ my $want_response;
+ $want_response = shift() if UNIVERSAL::isa($_[0], __PACKAGE__);
my ($ua, $url) = (@_ == 1 ? ($UA, shift()) : @_);
my $request = ref $url ? $url : {uri=>$url};
@@ -228,7 +229,7 @@
my $req = new HTTP::Request(@{$request}{'method','uri','headers','content'});
my $response = $ua->request($req);
- return wantarray ? ($response->content, $response) : $response->content;
+ return $want_response ? $response : $response->content;
}
sub simple_fetch {