Hi,

I kept getting error 401.

#!/usr/cisco/bin/perl5.6 -w
use strict;

use LWP::UserAgent;
use HTTP::Request::Common qw( POST );
use HTTP::Response;
use HTML::TreeBuilder;
use HTML::FormatText;
use HTML::Parse;
use URI::Heuristic;

$| = 1;

my $ua = LWP::UserAgent->new;

my $url=
'http://wwwin-swtools1.cisco.com/swtools/clearcase/qit/mockup/report/report_change_metrics.cgi';

my %a = ( 'id', 'CSCec29102' );
my $form_ref= [ %a ];

my $req = POST $url, $form_ref;

my $cont = $ua->request($req);

if ( $cont->is_success ) {
    my $content = $ua->request($req)->as_string;
    print "$content\nend\n";

    my $html = HTML::TreeBuilder->new();
    $html->parse($content);

    my $formatter = HTML::FormatText->new(leftmargin => 0, rightmargin =>
80);
    my $ascii = $formatter->format($html);
    print "$ascii\n\n";
} else {
    print $ua->request($req)->as_string . "\n";
}

richardd-u5% /tmp/a.pl
HTTP/1.1 401 (Unauthorized) Authorization Required
Connection: close
Date: Thu, 09 Oct 2003 04:13:57 GMT
Server: Apache/1.3.26 (Unix) PHP/4.2.2 mod_perl/1.27
WWW-Authenticate: Basic realm="wwwin-swtools"
Content-Type: text/html; charset=iso-8859-1
Client-Date: Thu, 09 Oct 2003 04:13:57 GMT
Client-Response-Num: 1
Client-Transfer-Encoding: chunked
Title: 401 Authorization Required

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>401 Authorization Required</TITLE>
</HEAD><BODY>
<H1>Authorization Required</H1>
This server could not verify that you
are authorized to access the document
requested.  Either you supplied the wrong
credentials (e.g., bad password), or your
browser doesn't understand how to supply
the credentials required.<P>
<P>Additionally, a 404 Not Found
error was encountered while trying to use an ErrorDocument to handle the
request.
<HR>
<ADDRESS>Apache/1.3.26 Server at wwwin-swtools1.cisco.com Port 80</ADDRESS>
</BODY></HTML>

Any clues?

thx,
Richard

Reply via email to