#!c:\perl\bin\perl.exe

use LWP::Simple;
for ($i=1; $i<3; $i++) {
	timeGetUrl('http://wetterhorn.uccs.edu:8080/cs622/hw/hw1.htm');
	timeGetUrl('http://wetterhorn.uccs.edu:8080/cs622/hw/hw1_ht1.gif');
	
}

use LWP::UserAgent;
$ua = LWP::UserAgent->new;
my $req = HTTP::Request->new(POST => 'http://wetterhorn.uccs.edu:8080/cgi-bin/cs622/purchase.pl');
$req->content_type('text/xml');
$xmldoc = "
<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>
<!--======= purhcase request example =======-->
<purchase>
  <customerName>CCL</customerName>
  <customerID>111222333</customerID>
  <item>
     <productID>309121544</productID>
     <productName>IBM Thinkpad T21</productName>
     <unitPrice>5000</unitPrice>
     <noOfUnits>10</noOfUnits>
     <subTotal>50000</subTotal>
  </item>
  <item>
     <productID>309121538</productID>
     <productName>Intel wireless LAN PC Card</productName>
     <unitPrice>200</unitPrice>
     <noOfUnits>10</noOfUnits>
     <subTotal>2000</subTotal>
  </item>
  <totalAmount>52000</totalAmount>
</purchase>";

print $xmldoc;
$req->content($xmldoc);
$time3=time;
my $res = $ua->request($req);
$time4=time;
$periodxml = $time4 -$time3;
print $res->as_string;
print "get response after submitting purchase.xml in $periodxml seconds\n";


sub timeGetUrl() {
	my ($url) = @_;
	$time1 = time;
	$doc = get $url;
	$length= length $doc;
        $time2 = time;
        $period = $time2 - $time1;
        print "get $url size $length in $period seconds\n";
}


