简体   繁体   中英

PHP send HTTP 200 ok response and if any error found/success, send that response afterwords. Is this possible in PHP?

My code requires sending a 200 ok response to a client that sends json data to my API code within 100 seconds.

My code has a long process of cloning assets, creating texts to be stored in tokens, and other processes, which takes a lot of time, hence the platform sends a timeout request alert, which is what I'm trying to avoid.

So how, if possible, in PHP can I send the code 200 response telling the platform that the API has successfully received the valid json and then after processing the request json send out any errors or success messages. My code lives on windows server and most of the time I run this API code via Postman to test/configure etc.

1) make it go faster (really, 100 seconds to handle a single request is ridiculous) When you say "cloning assets" are we talking about DNA here?

2) handle the processing asynchronously - the first request submits a task for processing and returns a reference to the client, the client can then poll the state poll the task later.

3) Fully validate the client data and the ability of the server to service the request and make a response, then do the work (BTW this sucks as a solution)

是的,可以在php中设置标头中的响应代码。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM