如何获取 POE::Component::Client::HTTP 的响应?
我的组件
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 对象(或任何东西)到响应处理程序。我做错了什么?
My component
POE::Component::Client::HTTP->spawn(
Agent => "MyScript/1.0",
Alias => 'browser',
Timeout => 60,
FollowRedirects => 3,
);
This is the event handler of another POE component from where the HTTP request is sent
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
}
I checked my Webserver logs and the HTTP request is sent correctly but it doesn't send the HTTP::Response object (or anything) to the response handler. What did I do wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
抱歉,这个问题可以结束了。我应该使用响应处理程序创建一个 POE::Session 并从它的 _start 处理程序中调用 $kernel->post() 。
Sorry, this question can be closed. I was supposed to create a POE::Session with the response handlers and call $kernel->post() from it's _start handler.