docs: def read_header(filename, ext=0, extver=None, case_sensitive=False, **keys):
      """
      Convenience function to read the header from the specified FITS HDU
  
      The FITSHDR allows access to the values and comments by name and
      number.
  
      parameters
      ----------
      filename: string
          A filename.
      ext: number or string, optional
          The extension.  Either the numerical extension from zero
          or a string extension name. Default read primary header.
      extver: integer, optional
          FITS allows multiple extensions to have the same name (extname).  These
          extensions can optionally specify an EXTVER version number in the
          header.  Send extver= to select a particular version.  If extver is not
          sent, the first one will be selected.  If ext is an integer, the extver
          is ignored.
      case_sensitive: bool, optional
          Match extension names with case-sensitivity.  Default is False.
      """
  
      dont_create = 0
      try:
          hdunum = ext+1
      except TypeError:
          hdunum = None
  
      _fits = _fitsio_wrap.FITS(filename, READONLY, dont_create)
  
      if hdunum is None:
          extname = mks(ext)
          if extver is None:
              extver_num = 0
          else:
              extver_num = extver
  
          if not case_sensitive:
              # the builtin movnam_hdu is not case sensitive
              hdunum = _fits.movnam_hdu(ANY_HDU, extname, extver_num)
          else:
              # for case sensitivity we'll need to run through
              # all the hdus
              found = False
              current_ext = 0
              while True:
                  hdunum = current_ext+1
                  try:
                      hdu_type = _fits.movabs_hdu(hdunum)  # noqa - not used
                      name, vers = _fits.get_hdu_name_version(hdunum)
                      if name == extname:
                          if extver is None:
                              # take the first match
                              found = True
                              break
                          else:
                              if extver_num == vers:
                                  found = True
                                  break
                  except OSError:
                      break
  
                  current_ext += 1
  
              if not found:
                  raise IOError(
                      'hdu not found: %s (extver %s)' % (extname, extver))
  
      return FITSHDR(_fits.read_header(hdunum))