Currently, the library uses the default Laravel HTTP Client. The client supports async() request, which return a promise which result can be retrieved later. This is a nice article explaining how. This would avoid blocking the request by waiting the response from reCAPTCHA servers.
In theory, it should be possible to queue the async reques, and resolve it only if the user requires to check the score. Since the user interacts with ReCaptchaResponse directly, the changes underneath would be opaque; nothing would change on the user-land.
After the response is sent, the request would be forcefully cancelled to avoid lingering pending requests (specially under Laravel Octane or similar). This means the middleware should have a terminate() method in which the response is forcefully cancelled.
public function terminate($request, $response)
{
$this->captchavel->cancelPendingRequest();
}
Currently, the library uses the default Laravel HTTP Client. The client supports
async()
request, which return a promise which result can be retrieved later. This is a nice article explaining how. This would avoid blocking the request by waiting the response from reCAPTCHA servers.In theory, it should be possible to queue the async reques, and resolve it only if the user requires to check the score. Since the user interacts with
ReCaptchaResponse
directly, the changes underneath would be opaque; nothing would change on the user-land.After the response is sent, the request would be forcefully cancelled to avoid lingering pending requests (specially under Laravel Octane or similar). This means the middleware should have a
terminate()
method in which the response is forcefully cancelled.