code: private static void encodeHeader(DnsQuery query, ByteBuf buf) {
          buf.writeShort(query.id());
          int flags = 0;
          flags |= (query.opCode().byteValue() & 0xFF) << 14;
          if (query.isRecursionDesired()) {
              flags |= 1 << 8;
          }
          buf.writeShort(flags);
          buf.writeShort(query.count(DnsSection.QUESTION));
          buf.writeShort(0); // answerCount
          buf.writeShort(0); // authorityResourceCount
          buf.writeShort(query.count(DnsSection.ADDITIONAL));
      }
docs: Encodes the header that is always 12 bytes long.
  
  @param query the query header being encoded
  @param buf   the buffer the encoded data should be written to