Add handling for cases where IOException is thrown from
httpurlconnection instead of responding with code 401.