Patch for proxy using NTLM
[email protected] ("Vincent G.") Thu, 4 Aug 2011 02:21:48 -0700 (PDT)
| Newsgroups | perl.libwww |
|---|---|
| Message-ID | <[email protected]> |
Hi,
Here is a patch to use NTLM authentication on proxy. Most of the code was already here.
Why is get_basic_credentials from UserAgent.pm returning nothing when $proxy is true ?
--- before/Ntlm.pm 2010-05-05 23:06:22.001000000 +0200
+++ LWP/Authen/Ntlm.pm 2011-08-04 10:29:52.641169700 +0200
@@ -13,7 +13,7 @@
$request, $arg, $size) = @_;
my($user, $pass) = $ua->get_basic_credentials($auth_param->{realm},
- $request->uri, $proxy);
+ ($proxy?$request->{proxy}:$request->uri), 0);
unless(defined $user and defined $pass) {
return $response;
@@ -31,10 +31,11 @@
ntlm_password($pass);
my $auth_header = $proxy ? "Proxy-Authorization" : "Authorization";
+ my $resp_header = $proxy ? "Proxy-Authenticate" : "WWW-Authenticate";
# my ($challenge) = $response->header('WWW-Authenticate');
my $challenge;
- foreach ($response->header('WWW-Authenticate')) {
+ foreach ($response->header($resp_header)){
last if /^NTLM/ && ($challenge=$_);
}
@@ -68,12 +69,12 @@
# was returned, in which case, we just send back the response
# object, as is
my $auth_value;
- if ($response->code ne '401') {
+ if ((!$proxy && $response->code ne '401') || ($proxy && $response->code ne '407')) {
return $response;
}
else {
my $challenge;
- foreach ($response->header('WWW-Authenticate')) {
+ foreach ($response->header($resp_header)) {
last if /^NTLM/ && ($challenge=$_);
}
$challenge =~ s/^NTLM //;