Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: AnyEvent::HTTPD::Request Dynamic Async Response

by Corion (Patriarch)
on Jun 06, 2022 at 06:23 UTC ( [id://11144440]=note: print w/replies, xml ) Need Help??


in reply to AnyEvent::HTTPD::Request Dynamic Async Response

You can respond even later, as the code in delayed_2_example shows:

$httpd->reg_cb ( '/test' => sub { my ($httpd, $req) = @_; $t = AnyEvent->timer (after => 2, cb => sub { my $txt = "CPU info:\n\n" . `cat /proc/cpuinfo`; $req->respond ([200, "ok", { 'Content-Type' => 'text/plain' } +, $txt]); }); }, );

So you can't "respond" until you have a meaningful content type, but that's OK as you can delay your response.

Replies are listed 'Best First'.
Re^2: AnyEvent::HTTPD::Request Dynamic Async Response
by sectokia (Pilgrim) on Jun 07, 2022 at 02:40 UTC
    Duh, Not sure why I thought you couldn't do that... Thanks.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11144440]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (9)
As of 2024-04-24 10:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found