lpereira / lwan

Experimental, scalable, high performance HTTP server
https://lwan.ws
GNU General Public License v2.0
5.92k stars 549 forks source link

Is there an example of sending HTTP response asynchronously? #238

Open bharat42 opened 6 years ago

bharat42 commented 6 years ago

In my implementation, for every HTTP request received, I need to make an asynchronous HTTP request to a remote server. I need to wait till the response is received from that remote server before I return a status code in my Lwan request handler function.

Instead of returning a status from the handler function, I was expecting to call a function like "lwan_send_response" with content as param once my handler is ready to send the response.

lpereira commented 6 years ago

There's no way, right now, to perform something like this efficiently. The only way, right now, is to use non-blocking sockets, and spin on a call to read(), yielding whenever read() returns -EAGAIN. Work on this has started, though, and it's partially implemented (to allow e.g. corooutines to sleep), but I haven't progressed much beyond what's on the tree right now.