def _parse_nghttpd2_output(self, output):
        """Parse the output of nghttpd2.

        nghttpd2 in verbose mode writes out the HTTP/2
        headers that the client had sent.
        """
        lines = output.decode("utf-8").splitlines()
        stream_id = None
        for line in lines:
            m = re.search(r"recv HEADERS frame.*stream_id=(\d+)", line)
            if m:
                stream_id = m.group(1)
                break

        assert stream_id is not None, \
               "Failed to find HEADERS frame in nghttpd2 output"

        pseudo_headers = []
        headers = []
        for line in lines:
            m = re.search(rf"recv \(stream_id={stream_id}\) (.*)", line)
            if m:
                header = m.group(1)
                # If the headers starts with ":" it is a pseudo-header,
                # i.e. ":authority". In this case keep only the header name and
                # discard the value
                if header.startswith(":"):
                    m = re.match(r"(:\w+):", header)
                    if m:
                        pseudo_headers.append(m.group(1))
                else:
                    headers.append(header)

        return pseudo_headers, headers
Parse the output of nghttpd2.

        nghttpd2 in verbose mode writes out the HTTP/2
        headers that the client had sent.
        
tests/test_impersonate.py