code: async def read_headers(stream: asyncio.StreamReader) -> "Headers":
      
      # https://tools.ietf.org/html/rfc7230#section-3.2
  
      # We don't attempt to support obsolete line folding.
  
      headers = Headers()
      for _ in range(MAX_HEADERS + 1):
          line = await read_line(stream)
          if line == b"":
              break
  
          # This may raise "ValueError: not enough values to unpack"
          raw_name, raw_value = line.split(b":", 1)
          if not _token_re.fullmatch(raw_name):
              raise ValueError("Invalid HTTP header name: %r" % raw_name)
          raw_value = raw_value.strip(b" \t")
          if not _value_re.fullmatch(raw_value):
              raise ValueError("Invalid HTTP header value: %r" % raw_value)
  
          name = raw_name.decode("ascii")  # guaranteed to be ASCII at this point
          value = raw_value.decode("ascii", "surrogateescape")
          headers[name] = value
  
      else:
          raise ValueError("Too many HTTP headers")
  
      return headers
docs: Read HTTP headers from ``stream``.
  
      ``stream`` is an :class:`~asyncio.StreamReader`.
  
      Return a :class:`Headers` instance
  
      Non-ASCII characters are represented with surrogate escapes.