code: def check_response_status(response, err_prefix="", session=None):
      """Check if response's status_code signals problem with authentication etc
  
      ATM succeeds only if response code was 200
      """
      if not err_prefix:
          err_prefix = "Access to %s has failed: " % response.url
      # 401 would be for digest authentication mechanism, or if we first ask which mechanisms are
      # supported.... must be linked into the logic if we decide to automagically detect which
      # mechanism or to give more sensible error message
      err_msg = err_prefix + "status code %d" % response.status_code
      if response.status_code in {404}:
          # It could have been that form_url is wrong, so let's just say that
          # TODO: actually may be that is where we could use tagid and actually determine the form submission url
          raise DownloadError(err_prefix + "not found")
      elif 400 <= response.status_code < 500:
          raise AccessDeniedError(
              err_msg,
              supported_types=process_www_authenticate(
                  response.headers.get("WWW-Authenticate")
              ),
              status=response.status_code,
          )
      elif response.status_code in {200}:
          pass
      elif response.status_code in {301, 302, 307}:
          # TODO: apparently tests do not exercise this one yet
          if session is None:
              raise AccessFailedError(
                  err_msg + " no session was provided",
                  status=response.status_code,
              )
          redirs = list(
              session.resolve_redirects(response, response.request)
          )
          if len(redirs) > 1:
              lgr.warning(
                  "Multiple redirects aren't supported yet.  Taking first"
              )
          elif len(redirs) == 0:
              raise AccessFailedError(
                  "No redirects were resolved",
                  status=response.status_code,
              )
          raise UnhandledRedirectError(
              err_msg, url=redirs[0].url, status=response.status_code
          )
      else:
          raise AccessFailedError(err_msg, status=response.status_code)
  
imports: import re
  import requests
  import requests.auth
  from requests.utils import parse_dict_header
  import io
  from time import sleep
  from ..None import __version__
  from ..utils import ensure_list_from_str, ensure_dict_from_str, ensure_bytes
  from ..dochelpers import borrowkwargs
  from ..ui import ui
  from ..utils import auto_repr
  from ..support.network import get_url_filename
  from ..support.network import get_response_disposition_filename
  from ..support.network import rfc2822_to_epoch
  from ..support.cookies import cookies_db
  from ..support.status import FileStatus
  from ..support.exceptions import AccessDeniedError, AccessFailedError, CapturedException, DownloadError, UnhandledRedirectError
  from .base import Authenticator
  from .base import BaseDownloader, DownloaderSession
  from logging import getLogger
  from ..log import LoggerHelper
label_desc: Use image node_id 2 for calling a global function with example usage: check_response_status(response, err_prefix, session) without return types