private ByteBuffer readBufferRFC6455(boolean mask, ByteBuffer request) {
        int min = mask ? 6 : 2;
        if (request.remaining() < min) {
            return null;
        }

        byte header1 = request.get();
        byte header2 = request.get();

        PayloadLengthType payloadLengthType = PayloadLengthType.valueOf(header2);
        byte payloadLength1 = (byte) (header2 & 0x7F);
        long payloadLength2 = payloadLength1;

        switch (payloadLengthType) {
            case LEN_16:
                min += 2;
                if (request.remaining() < min) {
                    return null;
                }
                payloadLength2 = 0xFFFF & request.getShort();
                break;
            case LEN_63:
                min += 8;
                if (request.remaining() < min) {
                    return null;
                }
                payloadLength2 = 0x7FFFFFFFFFFFFFFFL & request.getLong();
                break;
        }

        byte[] seed = new byte[4];
        if (mask) {
            request.get(seed);
        }
        if (request.remaining() < payloadLength2) {
            request.position(request.position() - min);
            return null;
        }

        request.limit(min + (int) payloadLength2);

        if (mask) {
            MaskDecoder decoder = new MaskDecoder(seed);
            decoder.decode(request);
        }
        System.out.println("PL:" + payloadLength2 + " PO:" + request.position() + " OFFSET:" + request.arrayOffset() + "CAPA:" + request.capacity());
        request.rewind();
        ByteBuffer tmp = request.slice();
        return tmp;
    }