in reply to Re: LWP, SSL, 302
in thread LWP, SSL, 302

Here is some ancient code of mine that did exactly that, except the purpose was to *disallow* all redirects, including GETs. Its probably just a simple tweak to reverse the logic, and allow redirects on everything including POSTs. Anyway, here is the code:

# file: # /usr/local/perllibs/LWP/UserAgent/NoRedirects.pm # usage: # use LWP::NoRedirects; # use LWP::UserAgent; package LWP::UserAgent::NoRedirects; use base qw(LWP::UserAgent); sub new { my ($class, $base) = @_; my $parser = new LWP::UserAgent; $parser->{base} = $base; bless $parser, $class; } sub redirect_ok { return 0; } 1;

-Blake

Replies are listed 'Best First'.
Re: Re: Re: LWP, SSL, 302
by seanbo (Chaplain) on Aug 08, 2001 at 18:10 UTC
    I tried sub-classing LWP::UserAgent and overriding the redirect_ok method to return one everytime as blakem did in his code (but opposite) here.
    #I changed the return value sub redirect_ok { return 1; } #Now I get no page returned.


    seanbo
Re: Re: Re: LWP, SSL, 302
by seanbo (Chaplain) on Aug 08, 2001 at 22:08 UTC
    OK. Here is what I did to force the redirect on the POST.
    package LWP::UserAgent::ForceRedirects; use LWP::UserAgent; use base qw(LWP::UserAgent); sub new { my ($class, $base) = @_; my $parser = new LWP::UserAgent; $parser->{base} = $base; bless $parser, $class; } sub redirect_ok { my ($self, $request) = @_; print "Redirecting to: " . $request->url() . "...\n"; return 1; } 1;
    here is the output
    C:\TEMP>perl -w bcbs.pl Redirecting to: https://XXX.XXX.XXX.XXX/?&STCO=1O3F9cqwYA2QAAB6EH0k&ST +COEND... Redirecting to: https://XXX.XXX.XXX.XXX/?&STCO=2O3F9cqwYA2QAAB6EH0k&ST +COEND...


    seanbo