Hi, I have a script that has been working for some web pages require digest authentication. However, I just came across a new webpage that it fails to work. The script is as shown below. The realm is "ty3.asia.dummy.com:8096" which contains ":". At first I suspect this breaks the code but after reading how Digest uses MD5, it doesn't seem to be the root cause. Appreciate if anyone can shred some light on this.
#!/usr/bin/perl -w use warnings; use strict; use LWP::UserAgent; use URI; my $username="admin"; my $password="admin"; my $realm = "ty3.asia.dummy.com:8096"; my $url=qw(http://ty3.asia.dummy.com:8096/application); my $u = URI->new($url); my $host = $u->host; my $port = $u->port; my $hostport = "$host:$port"; my $ua = LWP::UserAgent->new(keep_alive => 1); $ua->credentials($hostport,$realm,$username,$password); my $response = $ua->get($url); my $content = $response->content; print "$content";
The Wireshark header traffic capture of the problematic webpage is as shown below. Keep-live is gone in the "Connection" field of the second GET message. How to add it back?
GET /application HTTP/1.1 TE: deflate,gzip;q=0.3 Keep-Alive: 300 Connection: Keep-Alive, TE Host: ty3.asia.dummy.com:8096 User-Agent: libwww-perl/6.04 HTTP/1.1 401 Unauthorized Pragma: No-cache Cache-Control: no-cache Expires: Thu, 01 Jan 1970 09:00:00 JST WWW-Authenticate: Digest realm="ty3.asia.dummy.com:8096", qop="auth", +nonce="d7757e011940461afd9baf04d54b0858", opaque="481c532d006d5dfa105 +44ae8b0adbed2" Content-Type: text/html;charset=utf-8 Content-Length: 954 Date: Wed, 18 Apr 2012 03:44:49 GMT Server: Apache-Coyote/1.1 GET /application HTTP/1.1 TE: deflate,gzip;q=0.3 Connection: TE Authorization: Digest username="admin", realm="ty3.asia.dummy.com:8096 +", qop="auth", algorithm="MD5", uri="/application", nonce="d7757e0119 +40461afd9baf04d54b0858", nc="00000001", cnonce="4f8e38b1", response=" +b9d9cf87cb315f82b8bbd0cf4d68d175", opaque="481c532d006d5dfa10544ae8b0 +adbed2" Host: jty3.asia.dummy.com:8096 User-Agent: libwww-perl/6.04 HTTP/1.1 401 Unauthorized Pragma: No-cache Cache-Control: no-cache Expires: Thu, 01 Jan 1970 09:00:00 JST WWW-Authenticate: Digest realm="ty3.asia.dummy.com:8096", qop="auth", +nonce="d5dfe8c5a4f563bdbafdfe6fe1a29118", opaque="dfb683538f7c122c0c6 +1181a52919473" Content-Type: text/html;charset=utf-8 Content-Length: 954 Date: Wed, 18 Apr 2012 03:44:49 GMT Server: Apache-Coyote/1.1
In reply to LWP not working with digest authentication by sophate
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |