A. Sinan Unur said:
I would have expected you to ... provide a minimal but complete
script that still exhibits the problem.
As should have been evident from my original post. I have code that
retrieves the correct result on one computer but not when run on another
computer (both same flavour of Unix) - so I'd not expect to find a fatal
error in the Perl scripts below.
On computer-A, with proxy-A, the clients return
...
"37.5 C = 99.5 F"
On computer-B, with proxy-B, the clients fail:
...
"407 Proxy Authentication Required"
client1 - relies on (undocumented?) environment variables
Korn shell:
export HTTP_proxy=
http://proxy.example.com \
HTTP_proxy_user=Dirk \
HTTP_proxy_pass=foo
../soaptempclient1.pl
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
#!/usr/bin/perl -w
use strict;
use warnings;
use SOAP::Lite;
my $c = shift @ARGV;
$c = 37.5 unless $c;
foreach (qw(HTTP_proxy HTTP_proxy_user HTTP_proxy_pass)) {
print "$_='$ENV{$_}'\n" unless not defined $ENV{$_};
}
print
"$c C = ",
SOAP::Lite
-> uri('
http://www.example.org/Temperatures')
-> proxy ('
http://www.example.org/cgi-bin/soaptemp.pl')
-> c2f($c)
-> result,
" F\n";
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
client2 explicitly sets credentials using an approach that is not
explicitly documented anywhere I have found so far. Note that the user
and password for the HTTP proxy are "Dirk" and "foo" respectively. The
SOAP endpoint does not require authentication.
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
#!/usr/bin/perl -w
use strict;
use warnings;
use SOAP::Lite;
my $c = shift @ARGV;
$c = 37.5 unless $c;
foreach (qw(HTTP_proxy HTTP_proxy_user HTTP_proxy_pass)) {
print "$_='$ENV{$_}'\n" unless not defined $ENV{$_};
}
print
"$c C = ",
SOAP::Lite
-> uri('
http://www.example.org/Temperatures')
-> proxy ('
http://www.example.org/cgi-bin/soaptemp.pl',
proxy => ['http' => '
http://Dirk:[email protected]:8080'])
-> c2f($c)
-> result,
" F\n";
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
server script soaptemp.pl
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
#!/usr/bin/perl -w
use SOAP::Transport::HTTP;
SOAP::Transport::HTTP::CGI
-> dispatch_to('Temperatures')
-> handle;
package Temperatures;
sub f2c {
my ($class, $f) = @_;
return 5/9*($f-32);
}
sub c2f {
my ($class, $c) = @_;
return 32+$c*9/5;
}
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
For proxy-A, I use Squid. In squid.conf I added
authenticate_program /usr/local/bin/squidauth.pl
acl authentic proxy_auth REQUIRED
http_access allow authentic
http_access deny all
proxy_auth_realm Ians Proxy
squidauth.pl (verbatim from squid docs) is
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
#!/usr/bin/perl -w
$|=1; # no buffering, important!
while (<>) {
chop;
($u,$p) = split;
$ans = &check($u,$p);
print "$ans\n";
}
sub check {
local($u,$p) = @_;
return 'ERR' unless (defined $p && defined $u);
return 'OK' if ('Dirk' eq $u);
return 'OK' if ('Sekrit' eq $p);
return 'ERR';
}
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
I'll have to get the proxy-B administrator to check that it accepts
basic authentication (as opposed to NTLM, Digest or others only)
In my view, HTTP-proxy authentication *could* be better documented in
the SOAP::Lite docs. YMMV.