lrequest() library.. (Retrieves redirected documents)

bcutter@pdn.paradyne.com
Fri, 8 Jul 94 13:56:29 EDT


I'd like to submit the following code/interface to the libwww-perl
distribution.

The following code is equivalent to &www'request, except that it checks
the returned headers to see if there is a location redirect, and if
so it retrieves the Location/URI redirected document.

This functionality is similar to stat/lstat except reversed..
stat() will stat a symbolic link if it exists, lstat will
stat the link itself... in my example below, request() will
return the link, and lrequest() will return document
the Location/link points to...

Here's the suggested code/interface...

sub www'lrequest {
  # if it's not a http request, don't parse headers for Location/URI..
  return &www'request(@_) unless ($_[1] =~ /^\s*http:/i);
  # Arguments to &www'lrequest
  #local($method,$url,*headers,*content,$timeout) = @_;
#  local($method,$url,*headers,*content,$timeout) = 
#    (shift,shift,shift,shift,shift);
  local($method) = shift(@_);
  local($url) = shift(@_);
  local(*headers) = shift(@_);
  local(*content) = shift(@_);
  local($timeout) = shift(@_);

  local($response,%lheaders);

  while(1) {
    %lheaders = %headers;
    $response = &www'request($method, $url, *lheaders, *content, $timeout);
    last unless($response =~ /^[23]/);
    if ($lheaders{'location'}) {
      $url = $lheaders{'location'};
      $url =~ s/^\s+//;
      $url =~ s/\s+$//;
    } elsif ($lheaders{'uri'}) {
      $url = $lheaders{'uri'};
      $url =~ s/\s*;.*$//;
      $url =~ s/^\s+//;
      $url =~ s/\s+$//;
    } else { last; }
  }
  return($response);
}

...I wrote this routine as part of a package that checks to see if
remote documents have been recently modified (by Last-Modified or
checksum)  When I run this program and use the lrequest() routine,
I get "Bad Free() ignored" errors...  I believe this is because
of the way I'm passing the pointers to &www'request() ... and
as you can see above, I've tried to pass it several different
ways..

I'd appreciate it if anyone can point me in the direction of
the problem..  Included below is sample debugging output of
my program allong with the error messages being generate from
perl...

Checking http://wwwifa.unm.edu:80/~quotes/

Checking http://wwwhome.paradyne.com:80/esce/admin/

Checking http://life.anu.edu.au/education/hypermedia.html
Bad free() ignored at /home/natas/bcutter/dev/perl/html/w3new/lib/libwww-perl-0.11/www.pl line 101.

Checking http://www.quadralay.com/www/Crypt/Crypt.html
Bad free() ignored at /home/natas/bcutter/dev/perl/html/w3new/lib/libwww-perl-0.11/www.pl line 101.

Checking http://www.cs.colorado.edu/home/mcbryan/useful.html
Bad free() ignored at /home/natas/bcutter/dev/perl/html/w3new/lib/libwww-perl-0.11/www.pl line 101.

Checking http://siva.cshl.org/wusage.html
Bad free() ignored at /home/natas/bcutter/dev/perl/html/w3new/lib/libwww-perl-0.11/www.pl line 101.

Checking http://www.bsdi.com/HTTP:TNG/MIME-ClientProfile.html


-Brooks
bcutter@paradyne.com