Loading ...
Sorry, an error occurred while loading the content.

Possible to ovrride LWP::UserAgent?

Expand Messages
  • Mike Schroeder
    Adding an environment variable for HTTP_proxy on my client wxPerl app worked great to get around proxy firewalls - you gotta love when Perl makes hard things
    Message 1 of 3 , Jun 4, 2004
    • 0 Attachment
      Adding an environment variable for HTTP_proxy on my client wxPerl app
      worked great to get around proxy firewalls - you gotta love when Perl
      makes hard things easy.

      Is it possible to override the LWP::UserAgent used by
      SOAP::Transport::HTTP to use something like LWP::UserAgent::ProxyAny --
      it has the feature of checking a Win32 client's Internet Explorer
      settings for proxy settings in addition to checking the environment
      variable - useless for my GTK or OS X clients, but would be very handy
      for the majority of Win32 clients. I couldn't find anything in the docs
      or the mailing list about this - unless I just missed it.

      Thanks in advance for any ideas.
    • Byrne Reese
      The current architecture of SOAP::Lite doesn t make this terribly easy. That is because LWP::UserAgent is the base class for SOAP::Transport::HTTP::Client. But
      Message 2 of 3 , Oct 22, 2004
      • 0 Attachment
        The current architecture of SOAP::Lite doesn't make this terribly easy. That is because LWP::UserAgent is the base class for SOAP::Transport::HTTP::Client.

        But in SOAP::Lite 0.65 Beta 2, I have included a work around. It is not elegant, but it works. In the next release, you can use the following code to change the UserAgent for SOAP::Transport::HTTP::Client.
        #!/usr/bin/perl -w
        use SOAP::Lite +trace => qw(debug);
        use SOAP::Transport::HTTP;
        use My::UserAgent;
        use strict;
        my $uri = "urn:Majordojo:TemperatureService";
        my $proxyUrl = "http://localhost/cgi-bin/soaplite.cgi";

        $SOAP::Transport::HTTP::Client::USERAGENT_CLASS = "My::UserAgent2";

        my $soap = SOAP::Lite
           ->uri($uri)
           ->proxy($proxyUrl);
        $soap->c2f(SOAP::Data->name('temperature' => 100));
        There is one caveat: the class you specify as the USERAGENT_CLASS MUST INHERIT FROM LWP::UserAgent. If it does not, because SOAP::Lite depends upon LWP::UserAgent method calls, SOAP::Lite will issue a die command.

        This needs to be tested. So who is signing up for it?

        Byrne

        PS. I have just checked these changed into CVS.

        Mike Schroeder wrote:
        Adding an environment variable for HTTP_proxy on my client wxPerl app
        worked great to get around proxy firewalls - you gotta love when Perl
        makes hard things easy.

        Is it possible to override the LWP::UserAgent used by
        SOAP::Transport::HTTP to use something like LWP::UserAgent::ProxyAny --
        it has the feature of checking a Win32 client's Internet Explorer
        settings for proxy settings in addition to checking the environment
        variable - useless for my GTK or OS X clients, but would be very handy
        for the majority of Win32 clients.  I couldn't find anything in the docs
        or the mailing list about this - unless I just missed it.

        Thanks in advance for any ideas.

      • Mike Schroeder
        I ll try and work this change into our code in the next week and let you know how it goes... Thanks! ... From: Byrne Reese [mailto:byrne@majordojo.com] Sent:
        Message 3 of 3 , Oct 22, 2004
        • 0 Attachment
          I'll try and work this change into our code in the next week and let you know how it goes...
           
           
          Thanks!
          -----Original Message-----
          From: Byrne Reese [mailto:byrne@...]
          Sent: Friday, October 22, 2004 4:25 PM
          To: Mike Schroeder
          Cc: soaplite@yahoogroups.com
          Subject: Re: [soaplite] Possible to ovrride LWP::UserAgent?

          The current architecture of SOAP::Lite doesn't make this terribly easy. That is because LWP::UserAgent is the base class for SOAP::Transport::HTTP::Client.

          But in SOAP::Lite 0.65 Beta 2, I have included a work around. It is not elegant, but it works. In the next release, you can use the following code to change the UserAgent for SOAP::Transport::HTTP::Client.
          #!/usr/bin/perl -w
          use SOAP::Lite +trace => qw(debug);
          use SOAP::Transport::HTTP;
          use My::UserAgent;
          use strict;
          my $uri = "urn:Majordojo:TemperatureService";
          my $proxyUrl = "http://localhost/cgi-bin/soaplite.cgi";

          $SOAP::Transport::HTTP::Client::USERAGENT_CLASS = "My::UserAgent2";

          my $soap = SOAP::Lite
             ->uri($uri)
             ->proxy($proxyUrl);
          $soap->c2f(SOAP::Data->name('temperature' => 100));
          There is one caveat: the class you specify as the USERAGENT_CLASS MUST INHERIT FROM LWP::UserAgent. If it does not, because SOAP::Lite depends upon LWP::UserAgent method calls, SOAP::Lite will issue a die command.

          This needs to be tested. So who is signing up for it?

          Byrne

          PS. I have just checked these changed into CVS.

          Mike Schroeder wrote:
          Adding an environment variable for HTTP_proxy on my client wxPerl app
          worked great to get around proxy firewalls - you gotta love when Perl
          makes hard things easy.

          Is it possible to override the LWP::UserAgent used by
          SOAP::Transport::HTTP to use something like LWP::UserAgent::ProxyAny --
          it has the feature of checking a Win32 client's Internet Explorer
          settings for proxy settings in addition to checking the environment
          variable - useless for my GTK or OS X clients, but would be very handy
          for the majority of Win32 clients.  I couldn't find anything in the docs
          or the mailing list about this - unless I just missed it.

          Thanks in advance for any ideas.


        Your message has been successfully submitted and would be delivered to recipients shortly.