【问题标题】:How do I get the responses from POE::Component::Client::HTTP?如何从 POE::Component::Client::HTTP 获取响应?
【发布时间】:2010-12-26 09:11:30
【问题描述】:

我的组件

  POE::Component::Client::HTTP->spawn(
        Agent     => "MyScript/1.0",
        Alias     => 'browser',
        Timeout   => 60,
        FollowRedirects => 3,
  );

这是发送 HTTP 请求的另一个 POE 组件的事件处理程序

 sub connected {
     my ($heap,$kernel) = @_[HEAP,KERNEL];
     my $request = POST 'http://mydomain.com', [qw(hello world this is my script)];
     $kernel->post('browser','request','response',$request);
   }

 sub response {
     print "I am inside the response handler!\n"; # It never reaches here
   }

我检查了我的 Web 服务器日志,并且 HTTP 请求已正确发送,但它没有将 HTTP::Response 对象(或任何东西)发送到响应处理程序。我做错了什么?

【问题讨论】:

    标签: perl poe


    【解决方案1】:

    对不起,这个问题可以结束了。我应该使用响应处理程序创建一个 POE::Session 并从它的 _start 处理程序调用 $kernel->post()。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-01-16
      • 2013-07-01
      • 1970-01-01
      • 2022-06-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多