• 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' );


    
                                        
    
  • 相关阅读:
    SpringCloud学习笔记(2):使用Ribbon负载均衡
    SpringCloud学习笔记(1):Eureka注册中心
    Spring发送电子邮件
    CentOS7.5安装部署GitLab流程
    Shell流程控制及循环
    Shell的条件测试表达式
    Shell变量的数值运算
    Shell脚本简单入门
    Flutter Weekly Issue 58
    Android 开发技术周报 Issue#282
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13350627.html
Copyright © 2020-2023  润新知