docs: def _detect_type_load_headers(self, stream,
                                    statusline=None, known_format=None):
          """ If known_format is specified ('warc' or 'arc'),
          parse only as that format.
  
          Otherwise, try parsing record as WARC, then try parsing as ARC.
          if neither one succeeds, we're out of luck.
          """
  
          if known_format != 'arc':
              # try as warc first
              try:
                  rec_headers = self.warc_parser.parse(stream, statusline)
                  return 'warc', rec_headers
              except StatusAndHeadersParserException as se:
                  if known_format == 'warc':
                      msg = 'Invalid WARC record, first line: '
                      raise ArchiveLoadFailed(msg + str(se.statusline))
  
                  statusline = se.statusline
                  pass
  
          # now try as arc
          try:
              rec_headers = self.arc_parser.parse(stream, statusline)
              return self.arc_parser.get_rec_type(), rec_headers
          except StatusAndHeadersParserException as se:
              if known_format == 'arc':
                  msg = 'Invalid ARC record, first line: '
              else:
                  msg = 'Unknown archive format, first line: '
              raise ArchiveLoadFailed(msg + str(se.statusline))