Added some checks to prevent Undefined index notices

When the response content is empty, then an Undefined index notice will occur.