Tony -
Not sure WHY not allowing redirects on POSTs is the default, perhaps
someone else on the list can help. I do know that the code snippet I
sent works for me. The man page says something like "subclasses might
want to override this".
I beleive I found the solution of the redirect_ok override on an
archive of the libwww list.
However changing the request method was something I had to discover by
experimentation. The problem I was having was that when I submitted a
certain form, it would go through several iterations of a redirect
loop and end up back at the same page I started from, whereas any web
browser would handle it correctly. I ended up using lynx compiled
with verbose logging and comparing the logs by hand. (ouch)
[EMAIL PROTECTED] writes:
> Hey Chris,
>
> My version of UserAgent.pm has redirect_ok returning a 0
> if the method is POST, do you know why this is in the default
> behavior? I've been having trouble getting https to work with multiple
> redirects and this may relate to that, just wondering why it defaults
> to saying you cannot redirect a POST method.
>
> Thanks,
>
> Tony
> >
> > In addition, I found that to mimic the behavior of web browsers on
> > sites that do multiple redirects, I had to enable redirects for the
> > POST method __AND__ when this occurrs, change the request method to
> > GET. (It took a lot of headaches to figure that one out ;) Here's
> > some more code :
> >
> >
> > # We need to subclass LWP::UserAgent in order to allow redirects on POSTS
> > # and fix some other problems. In other words, to make it behave like a
> > # 'real' web browser
> > @MyAgent::ISA = qw(LWP::UserAgent);
> > sub MyAgent::redirect_ok {
> > my ($self,$request)=@_;
> >
> > # *****************************************************
> > # IMPORTANT:
> > #
> > # POSTs that get redirected __MUST__ change the request
> > # method to GET!!!!
> > # *****************************************************
> > if ($request->method eq "POST") {
> > $request->method("GET");
> > }
> > return 1;
> > }
--
--------------------------------------------------------------
Fair Winds, Software Engineer and WWW developer
Chris Dunn MRM, inc.
Email: [EMAIL PROTECTED]
Phone: (919) 544-6500 Ext 228
Pager: (919) 506-0819
http://www.mrmnc.com
--------------------------------------------------------------