Close Connection and Keep Executing
-
02-06-2021 - |
Question
How can I return a 400 status code and close the connection, without aborting script execution? I'm looking to initiate execution of the script using <cfhttp>
but not wait for the script to end before returning.
La solution
You need to run the portion of the script you want to keep running after the connection is close, on a different thread.
Here's a tutorial on how to launch a new thread in Coldfusion.
Autres conseils
If you want to hit a new request triggered from in another request without waiting just set the cfhttp timeout to 0 and it will return right away without waiting on response. For continuing a script after returning a separate thread may be a better idea but if you are hitting something outside the server or really need a separate request then cfhttp timeout=0 should do the trick.