in reply to Re^7: LWP and Digest Authentication
in thread LWP and Digest Authentication

Nowhere in any of the examples or tutorials does it show the possibility of passing userid and password to either LWP->new or LWP::UserAgent->new. The former seems to accept no parameters, and the latter is defined as taking these options:

KEY DEFAULT ----------- -------------------- agent "libwww-perl/#.##" from undef conn_cache undef cookie_jar undef default_headers HTTP::Headers->new max_size undef max_redirect 7 parse_head 1 protocols_allowed undef protocols_forbidden undef requests_redirectable ['GET', 'HEAD'] timeout 180

So, you've overridden & extended new() in order to pass two parameters: userid & password.

And overridden get_basic_credentials() in order to associate those with a third parameter: realm, and maybe a fourth: url (which you pass in to get(), in order to do digest authentication.

Ain't OOP just a wonderful!

You know, it ain't like LWP was designed and implemented by some rank newbie.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

Replies are listed 'Best First'.
Re^9: LWP and Digest Authentication
by ikegami (Patriarch) on Feb 11, 2009 at 14:45 UTC

    Nowhere in any of the examples or tutorials does it show the possibility of passing userid and password to either LWP->new or LWP::UserAgent->new.

    Of course not. LWP->new doesn't exists and LWP::UserAgent->new does not have such a parameter. Why would the docs for one class document the parameters a method in another class could have?

    You know, it ain't like LWP was designed and implemented by some rank newbie.

    What I did is no different than how WWW::Mechanize adds a stack_depth argument to the constructor and overrides method content, among others.

    Feature addition through extension is a common practice, but not one I like. What if you had to extend two features?

    Update: Added "no different" paragraph.

      You don't find that having to

      1. Add a sub class to a class;
      2. Overide the constructor and add two instance variables; so that you can:
      3. Override a method and supply those two strings to the base class;

      An obscure and convoluted way of achieving the goal of passing a couple of parameters?


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

        The goal isn't to pass a couple of parameters. If you view it as parameters, there are 5 (user and password for realm on port of host).

        But more accurately, you want to override the auth mechanism in order to provide your own rules. A pluggable auth system or maybe just a callback would make more sense, but the work required would be similar.