Error handling, ssl support, and create my own version of sendfile
since file:sendfile doesn't support SSL.