Marcus Brito <[EMAIL PROTECTED]> writes:

> A quick question to LWP designers: what was the motivation for making
> the redirect_ok a method, instead of a property?

Because a property did not seem to be enough to express the conditions
under which to take this decision.  At the time the method was added I
had experience with languages where this was the common way of making
callbacks, but it was much easier to subclass in that language than it
is in Perl.

If I where to do it again today I would probably have made redirect_ok
a CODE attribute or something.  Similar to the direction that
HTML::Parser has taken.

> When a developer wants to make a single request using a different
> behavior than the default, and s/he must subclass UserAgent. Isn't
> this too overkill? I can think of a few situations where subclassing
> UserAgent would be actually better.

At the time I though subclassing would not be seen as a big drag.
Apparently it is.

> Wouldn't it be so much simpler if one could do something like this:
> $req = HTTP::Request->new('GET', '');
> $req->redirect_ok = 0;
> or
> $req = HTTP::Request->new('POST',
> '', [name1 => value1]);
> $req->redirect_ok = 1;

I think that's too simple.

Note that the last dev releases (since 5.53_94) has new redirect_ok
behaviour thanks to Sean.  You can modify which methods that are
redirected by setting the $ua->requests_redirectable() attribute.


Reply via email to