As of Drupal 8 drupal_exit()
has been removed, since it did not match Symfony's HTTP Kernel architecture.
Terminating the execution mid-request is discouraged. Instead modules that need to interrupt the request flow should throw the relevant HTTP Exception.
At any other occasion an instance of Response should be returned by the responsible Controller. For a redirect, return an instance of RedirectResponse or, for external, TrustedRedirectResponse (but be aware of bug #2950883: Allow form redirects to ignore ?destination query parameter).
D7
function image_style_deliver($style, $scheme) {
//......
if (!$lock_acquired) {
// Tell client to retry again in 3 seconds.
drupal_add_http_header('Status', '503 Service Unavailable');
drupal_add_http_header('Retry-After', 3);
print t('Image generation in progress. Try again shortly.');
drupal_exit();
}
//....
}
D8
use Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException;
function image_style_deliver($style, $scheme) {
//......
if (!$lock_acquired) {
// Tell client to retry again in 3 seconds.
throw new ServiceUnavailableHttpException(3, t('Image generation in progress. Try again shortly.'));
}
//....
}
It was possible to react to / change the URL being redirected, this is covered in the drupal_goto() has been removed change notice.