Send the content and end in one go
Remove unused require
Check when something went wrong with the request

If something goes wrong with the request, then we need to listen for
the error event. If so, just call callback(err) and get out of there.
Also added a test to check this using an unresolvable url.