#!/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"; #### 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="481c532d006d5dfa10544ae8b0adbed2" 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="d7757e011940461afd9baf04d54b0858", nc="00000001", cnonce="4f8e38b1", response="b9d9cf87cb315f82b8bbd0cf4d68d175", opaque="481c532d006d5dfa10544ae8b0adbed2" 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="dfb683538f7c122c0c61181a52919473" Content-Type: text/html;charset=utf-8 Content-Length: 954 Date: Wed, 18 Apr 2012 03:44:49 GMT Server: Apache-Coyote/1.1