develooper Front page | perl.libwww | Postings from December 2003

[PATCH] redirection in LWP::Simple

Thread Next
From:
Ward Vandewege
Date:
December 31, 2003 11:26
Subject:
[PATCH] redirection in LWP::Simple
Message ID:
20031231192637.GA12510@adp.vandewege.net
Hi there,

I had some trouble using LWP::Simple (v1.36 from Debian's libwww-perl package
version 5.69-4) with this url:

  http://www.tvgids.nl/

It turns out that site does an immediate redirect when hitting that url. The
webserver seems to be broken because it writes 'location:' instead of
'Location:' in the HTTP headers.

The latest LWP::Simple version (v1.38 from libwww-perl 5.76) does not
understand 'location' with lower-case first letter either.

The patch below (against v1.38) fixes LWP::Simple to accept a lowercase
'location' header. 

In the mindset of 'Be liberal in what you receive, and conservative in what
you send', is this worth adding to libwww-perl?

Thanks,
Ward Vandewege. 

--- Simple.pm   2003-12-31 14:15:59.000000000 -0500
+++ Simple.pm   2003-12-31 14:16:24.000000000 -0500
@@ -180,7 +180,7 @@
    if ($buf =~ m,^HTTP/\d+\.\d+\s+(\d+)[^\012]*\012,) {
        my $code = $1;
        #print "CODE=$code\n$buf\n";
-       if ($code =~ /^30[1237]/ && $buf =~ /\012Location:\s*(\S+)/) {
+       if ($code =~ /^30[1237]/ && $buf =~ /\012Location:\s*(\S+)/i) {
            # redirect
            my $url = $1;
            return undef if $loop_check{$url}++;

-- 
Pong.be         -( "Free Software as in free speech, not free beer. Think  )-
Virtual hosting -(       of freedom, not price." -- Richard Stallman       )-
http://pong.be  -(                                                         )-
GnuPG public key: http://gpg.dtype.org

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About