Fix for recursion problem with wrong http basic auth credentials

I got an "array_replace_recursive(): Argument #2 is not an array" error after supplying wrong http basic auth credentials multiple times. After fixing that problem I got another error saying "Undefined variable: result" which I could fix by pre-defining the variable (although I do not see a reason for doing so).