Does anyone know how to send a CGI response to Ruby before the CGI script completes?
I am creating a Fire-and-forget HTTP API. I want the client to send me data via HTTP and successfully return a response, and then look through the data and do some processing (without the client waiting for a response).
I tried several things that do not work, including fork. The following will just wait 5 seconds when called via HTTP.
require 'cgi'
cgi = CGI.new
cgi.out "text/plain" do
"1"
end
pid = fork
if pid
Process.detach pid
else
sleep 5
end
source
share