docs: def parse_record_stream(self, stream,
                              statusline=None,
                              known_format=None,
                              no_record_parse=False,
                              ensure_http_headers=False):
          """ Parse file-like stream and return an ArcWarcRecord
          encapsulating the record headers, http headers (if any),
          and a stream limited to the remainder of the record.
  
          Pass statusline and known_format to detect_type_loader_headers()
          to faciliate parsing.
          """
          (the_format, rec_headers) = (self.
                                       _detect_type_load_headers(stream,
                                                                 statusline,
                                                                 known_format))
  
          if the_format == 'arc':
              uri = rec_headers.get_header('uri')
              length = rec_headers.get_header('length')
              content_type = rec_headers.get_header('content-type')
              sub_len = rec_headers.total_len
              if uri and uri.startswith('filedesc://'):
                  rec_type = 'arc_header'
              else:
                  rec_type = 'response'
  
          elif the_format in ('warc', 'arc2warc'):
              rec_type = rec_headers.get_header('WARC-Type')
              uri = self._ensure_target_uri_format(rec_headers)
              length = rec_headers.get_header('Content-Length')
              content_type = rec_headers.get_header('Content-Type')
              if the_format == 'warc':
                  sub_len = 0
              else:
                  sub_len = rec_headers.total_len
                  the_format = 'warc'
  
          is_err = False
  
          try:
              if length is not None:
                  length = int(length) - sub_len
                  if length < 0:
                      is_err = True
  
          except (ValueError, TypeError):
              is_err = True
  
          # err condition
          if is_err:
              length = 0
  
          # limit stream to the length for all valid records
          if length is not None and length >= 0:
              stream = LimitReader.wrap_stream(stream, length)
  
  
          http_headers = None
  
          # load http headers if parsing
          if not no_record_parse:
              http_headers = self.load_http_headers(rec_type, uri, stream, length)
  
          # generate validate http headers (eg. for replay)
          if not http_headers and ensure_http_headers:
              http_headers = self.default_http_headers(length, content_type)
  
          return ArcWarcRecord(the_format, rec_type,
                               rec_headers, stream, http_headers,
                               content_type, length)