code: def _handle_response(response, server_config, synchronous=False, timeout=None):
      
      response.raise_for_status()
      if synchronous is True and response.status_code == ACCEPTED:
          return ForemanTask(
              server_config, id=response.json()['id']).poll(timeout=timeout)
      if response.status_code == NO_CONTENT:
          return
      if 'application/json' in response.headers.get('content-type', '').lower():
          return response.json()
      elif isinstance(response.content, bytes):
          return response.content.decode('utf-8')
      else:
          return response.content
docs: Handle a server's response in a typical fashion.
  
      Do the following:
  
      1. Check the server's response for an HTTP status code indicating an error.
      2. Poll the server for a foreman task to complete if an HTTP 202 (accepted)
         status code is returned and ``synchronous is True``.
      3. Immediately return if an HTTP "NO CONTENT" response is received.
      4. Determine what type of the content returned from server. Depending on
         the type method should return server's response, with all JSON decoded
         or just response content itself.
  
      :param response: A response object as returned by one of the functions in
          :mod:`nailgun.client` or the requests library.
      :param server_config: A `nailgun.config.ServerConfig` object.
      :param synchronous: Should this function poll the server?
      :param timeout: Maximum number of seconds to wait until timing out.
              Defaults to ``nailgun.entity_mixins.TASK_TIMEOUT``.