log the http response codes in the file
Posted
by dexter
on Stack Overflow
See other posts from Stack Overflow
or by dexter
Published on 2010-03-22T05:26:45Z
Indexed on
2010/03/22
7:31 UTC
Read the original article
Hit count: 295
perl
i have created HTTP::Request which looks like this:
#!/usr/bin/perl
require HTTP::Request;
require LWP::UserAgent;
require HTTP::Cookies;
$request = HTTP::Request->new(GET => 'http://www.google.com/');
$ua = LWP::UserAgent->new;
$cookie_jar = HTTP::Cookies->new();
$ua->cookie_jar($cookie_jar);
$cookie_jar->set_cookie(0,'testCookie','cookieValue','/','http://www.google.com/',80,0,0,86400,0);
$response = $ua->request($request);
if($response->is_success){
print "sucess\n";
print $response->code;
print "\n";
}
else {
print "fail\n";
die $response->code;
print "\n";
}
now, When i send Request: i want to log the http response codes in the file
please help thank you
© Stack Overflow or respective owner