code: def get_canonical_headers(headers):
      if headers is None:
          headers = []
      elif isinstance(headers, dict):
          headers = list(headers.items())
      if not headers:
          return [], []
      normalized = collections.defaultdict(list)
      for key, val in headers:
          key = key.lower().strip()
          val = MULTIPLE_SPACES.sub(" ", val.strip())
          normalized[key].append(val)
      ordered_headers = sorted((key, ",".join(val)) for key, val in normalized.items())
      canonical_headers = ["{}:{}".format(*item) for item in ordered_headers]
      return canonical_headers, ordered_headers