zoukankan      html  css  js  c++  java
  • 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' );


    
       
    
    
  • 相关阅读:
    Linux下环境变量配置错误 导致大部分命令不可以使用的解决办法
    问题1:kafka的message包括那些?
    zabbix4.4
    jdk1.8安装
    linux 环境python3安装
    Zabbix应用监控
    zabbix4.0.21部署
    AtCoder Beginner Contest 187
    Codeforces Round #690 (Div. 3)
    AtCoder Beginner Contest 185
  • 原文地址:https://www.cnblogs.com/zhaoyangjian724/p/6199760.html
Copyright © 2011-2022 走看看