Perl HTTP server

后端 未结 3 651
陌清茗
陌清茗 2020-12-29 16:49

I\'m new at Perl, and I have a question regarding HTTP servers and client APIs.

I want to write an HTTP server which accepts requests from HTTP clients. The problem

3条回答
  •  臣服心动
    2020-12-29 17:22

    A client example compliant with the synopsys from HTTP::Daemon :

     require LWP::UserAgent;
    
     my $ua = LWP::UserAgent->new;
     $ua->timeout(10);
     $ua->env_proxy;
    
     my $response = $ua->get('http://localhost:52798/xyzzy');
    
     if ($response->is_success) {
         print $response->decoded_content;  # or whatever
     }
     else {
         die $response->status_line;
     }
    

    You just need to adapt the port and maybe the host.

提交回复
热议问题