Added guard agains undefined index if no headers are set. This happens if the url is ftp