code: public void parse(ByteBuffer buffer) {
          try {
              while (true) {
                  switch (state) {
                      case HEADER: {
                          if (parseHeader(buffer)) {
                              break;
                          } else {
                              return;
                          }
                      }
                      case BODY: {
                          if (parseBody(buffer)) {
                              break;
                          } else {
                              return;
                          }
                      }
                      default: {
                          throw new IllegalStateException();
                      }
                  }
              }
          } catch (Throwable x) {
              log.error("HTTP2 parsing error", x);
              BufferUtils.clear(buffer);
              notifyConnectionFailure(ErrorCode.PROTOCOL_ERROR.code, "parser_error");
          }
      }
docs: <p>
  Parses the given {@code buffer} bytes and emit events to a
  {@link Listener}.
  </p>
  <p>
  When this method returns, the buffer may not be fully consumed, so
  invocations to this method should be wrapped in a loop:
  </p>
  <p>
  <pre>
  while (buffer.hasRemaining())
  parser.parse(buffer);
  </pre>
  
  @param buffer the buffer to parse