2009-02-07 74 views

回答

9

可以使用LWP的head()方法在下列方式

use LWP::UserAgent; 
$ua = LWP::UserAgent->new; 
$ua->head('<url>'); 
+0

幸运的是我从机械继承UserAgent :) – Geo 2009-02-07 14:03:29

3

这里有一个完整的例子:

use LWP::UserAgent; 

$ua = LWP::UserAgent->new; 
my $response = $ua->head('http://www.perl.com'); 

my $type = $response->content_type; 

print "The type is $type\n"; 

一些服务器呛HEAD请求,所以当我这样做,得到的错误任何类型,我重试与GET请求,只请求头几百字节的资源。

相关问题