perl lwp 获取请求头

<pre name="code" class="html">[root@dr-mysql01 ~]# cat getx.pl 
use LWP::UserAgent;
 $ua = LWP::UserAgent->new;
 @header = (
    'accept'=> "application/json",
    'content-type'=> "application/json",
    'apix-key'=> "e7b00871640c49567a37566ccd5c27e9",
    'User-Agent' => "Mozilla/8.0"
    );

$host="http://zjcap.cn";
$request = HTTP::Request->new(GET=>"$host");
$request->header(@header);
use Data::Dumper;
print Dumper($request);
 my $hdrs = $request->headers;
print "111111111111111111111
";
print Dumper($hdrs);
[root@dr-mysql01 ~]# perl getx.pl 
$VAR1 = bless( {
                 '_uri' => bless( do{(my $o = 'http://zjcap.cn')}, 'URI::http' ),
                 '_method' => 'GET',
                 '_content' => '',
                 '_headers' => bless( {
                                        'content-type' => 'application/json',
                                        'user-agent' => 'Mozilla/8.0',
                                        'apix-key' => 'e7b00871640c49567a37566ccd5c27e9',
                                        'accept' => 'application/json',
                                        '::std_case' => {
                                                          'apix-key' => 'Apix-Key'
                                                        }
                                      }, 'HTTP::Headers' )
               }, 'HTTP::Request' );
111111111111111111111
$VAR1 = bless( {
                 'content-type' => 'application/json',
                 'user-agent' => 'Mozilla/8.0',
                 'apix-key' => 'e7b00871640c49567a37566ccd5c27e9',
                 'accept' => 'application/json',
                 '::std_case' => {
                                   'apix-key' => 'Apix-Key'
                                 }
               }, 'HTTP::Headers' );



   

原文地址:https://www.cnblogs.com/zhaoyangjian724/p/6199759.html