WordPress / Requests

Requests for PHP is a humble HTTP request library. It simplifies how you interact with other sites and takes away all your worries.
https://requests.ryanmccue.info/
Other
3.57k stars 497 forks source link

Add documentation about the livecycle of a request #876

Open hirasso opened 4 months ago

hirasso commented 4 months ago

Hello there 👋👋

I have chosen this issue template since I don't know where else to post my question:

My Question

Are Requests being finished, even if the user that invoked the current script closes their browser?

Additional context

I ended up in this Repo since I source-dived wp-cron to find out how it worked. Turns out it sends a HTTP request from cron.php to wp-cron.php to invoke scheduled jobs:

$result = wp_remote_post( $cron_request['url'], $cron_request['args'] );

That call leads through a few other files to this request call in class-wp-http.php:

$requests_response = WpOrg\Requests\Requests::request( $url, $headers, $data, $type, $options );

Now I couldn't find any resources on the web about the question if this HTTP POST call will be finished, even if the current visitor closes their connection (e.g. browser tab) – or if it will be cancelled with the user session. That would be valuable information for scenarios where there would be long running processes that should be invoked by a cron job.

Source-diving the Requests library also is a bit over my head 😅 I'd be very grateful for any definite answer! It would be amazing to be pointed towards the relevant code, if it turns out that these requests will be finished, not matter what...