sendResource($rangeSet); } catch (InvalidRangeHeaderException $e) { \header("HTTP/1.1 400 Bad Request"); } catch (UnsatisfiableRangeException $e) { \header("HTTP/1.1 416 Range Not Satisfiable"); } catch (NonExistentFileException $e) { \header("HTTP/1.1 404 Not Found"); } catch (UnreadableFileException $e) { \header("HTTP/1.1 500 Internal Server Error"); } catch (SendFileFailureException $e) { if (!\headers_sent()) { \header("HTTP/1.1 500 Internal Server Error"); } echo "An error occurred while attempting to send the requested resource: {$e->getMessage()}"; } // It's usually a good idea to explicitly exit after sending a file to avoid sending any // extra data on the end that might corrupt the file exit;