@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof ByteBuf) { return ByteBufUtil.equals(this, (ByteBuf) obj); } return false; }
@Override public boolean equals(Object o) { return this == o || (o instanceof ByteBuf && ByteBufUtil.equals(this, (ByteBuf) o)); }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof ByteBuf) { return ByteBufUtil.equals(this, (ByteBuf) obj); } return false; }
@Override public boolean equals(Object o) { return this == o || (o instanceof ByteBuf && ByteBufUtil.equals(this, (ByteBuf) o)); }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof ByteBuf) { return ByteBufUtil.equals(this, (ByteBuf) obj); } return false; }
@Override public boolean equals(Object o) { return this == o || (o instanceof ByteBuf && ByteBufUtil.equals(this, (ByteBuf) o)); }
/** * Returns {@code true} if and only if the two specified buffers are * identical to each other as described in {@link ByteBuf#equals(Object)}. * This method is useful when implementing a new buffer type. */ public static boolean equals(ByteBuf bufferA, ByteBuf bufferB) { final int aLen = bufferA.readableBytes(); if (aLen != bufferB.readableBytes()) { return false; } return equals(bufferA, bufferA.readerIndex(), bufferB, bufferB.readerIndex(), aLen); }
/** * Returns the reader index of needle in haystack, or -1 if needle is not in haystack. */ public static int indexOf(ByteBuf needle, ByteBuf haystack) { // TODO: maybe use Boyer Moore for efficiency. int attempts = haystack.readableBytes() - needle.readableBytes() + 1; for (int i = 0; i < attempts; i++) { if (equals(needle, needle.readerIndex(), haystack, haystack.readerIndex() + i, needle.readableBytes())) { return haystack.readerIndex() + i; } } return -1; }
/** * Returns {@code true} if and only if the two specified buffers are * identical to each other as described in {@link ByteBuf#equals(Object)}. * This method is useful when implementing a new buffer type. */ public static boolean equals(ByteBuf bufferA, ByteBuf bufferB) { final int aLen = bufferA.readableBytes(); if (aLen != bufferB.readableBytes()) { return false; } return equals(bufferA, bufferA.readerIndex(), bufferB, bufferB.readerIndex(), aLen); }
/** * Returns the reader index of needle in haystack, or -1 if needle is not in haystack. */ public static int indexOf(ByteBuf needle, ByteBuf haystack) { // TODO: maybe use Boyer Moore for efficiency. int attempts = haystack.readableBytes() - needle.readableBytes() + 1; for (int i = 0; i < attempts; i++) { if (equals(needle, needle.readerIndex(), haystack, haystack.readerIndex() + i, needle.readableBytes())) { return haystack.readerIndex() + i; } } return -1; }
@VisibleForTesting static boolean isExpected(long errorCode, ByteBuf debugData) { // 'Error flushing' happens when a client closes the connection early. return errorCode == CODE_INTERNAL_ERROR && ByteBufUtil.equals(debugData, debugData.readerIndex(), ERROR_FLUSHING, 0, ERROR_FLUSHING_LEN); }
/** * Returns {@code true} if and only if the two specified buffers are * identical to each other as described in {@link ByteBuf#equals(Object)}. * This method is useful when implementing a new buffer type. */ public static boolean equals(ByteBuf bufferA, ByteBuf bufferB) { final int aLen = bufferA.readableBytes(); if (aLen != bufferB.readableBytes()) { return false; } return equals(bufferA, bufferA.readerIndex(), bufferB, bufferB.readerIndex(), aLen); }
/** * Returns the reader index of needle in haystack, or -1 if needle is not in haystack. */ public static int indexOf(ByteBuf needle, ByteBuf haystack) { // TODO: maybe use Boyer Moore for efficiency. int attempts = haystack.readableBytes() - needle.readableBytes() + 1; for (int i = 0; i < attempts; i++) { if (equals(needle, needle.readerIndex(), haystack, haystack.readerIndex() + i, needle.readableBytes())) { return haystack.readerIndex() + i; } } return -1; }
@Override protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception { int prefaceLength = CONNECTION_PREFACE.readableBytes(); int bytesRead = Math.min(in.readableBytes(), prefaceLength); if (!ByteBufUtil.equals(CONNECTION_PREFACE, CONNECTION_PREFACE.readerIndex(), in, in.readerIndex(), bytesRead)) { ctx.pipeline().remove(this); } else if (bytesRead == prefaceLength) { // Full h2 preface match, removed source codec, using http2 codec to handle // following network traffic ctx.pipeline() .remove(httpServerCodec) .remove(httpServerUpgradeHandler); ctx.pipeline().addAfter(ctx.name(), null, http2ServerHandler); ctx.pipeline().remove(this); ctx.fireUserEventTriggered(PriorKnowledgeUpgradeEvent.INSTANCE); } } }
@Override protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception { int prefaceLength = CONNECTION_PREFACE.readableBytes(); int bytesRead = Math.min(in.readableBytes(), prefaceLength); if (!ByteBufUtil.equals(CONNECTION_PREFACE, CONNECTION_PREFACE.readerIndex(), in, in.readerIndex(), bytesRead)) { ctx.pipeline().remove(this); } else if (bytesRead == prefaceLength) { // Full h2 preface match, removed source codec, using http2 codec to handle // following network traffic ctx.pipeline() .remove(httpServerCodec) .remove(httpServerUpgradeHandler); // 用业务线程池 ctx.pipeline().addAfter(bizGroup, ctx.name(), null, http2ServerHandler); ctx.pipeline().remove(this); ctx.fireUserEventTriggered(Http2ServerUpgradeHandler.PriorKnowledgeUpgradeEvent.INSTANCE); } } }
@Override protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception { int prefaceLength = CONNECTION_PREFACE.readableBytes(); int bytesRead = Math.min(in.readableBytes(), prefaceLength); if (!ByteBufUtil.equals(CONNECTION_PREFACE, CONNECTION_PREFACE.readerIndex(), in, in.readerIndex(), bytesRead)) { ctx.pipeline().remove(this); } else if (bytesRead == prefaceLength) { // Full h2 preface match, removed source codec, using http2 codec to handle // following network traffic ctx.pipeline() .remove(httpServerCodec) .remove(httpServerUpgradeHandler); // 用业务线程池 ctx.pipeline().addAfter(bizGroup, ctx.name(), null, http2ServerHandler); ctx.pipeline().remove(this); ctx.fireUserEventTriggered(Http2ServerUpgradeHandler.PriorKnowledgeUpgradeEvent.INSTANCE); } } }
if (bytesRead == 0 || !ByteBufUtil.equals(in, in.readerIndex(), clientPrefaceString, clientPrefaceString.readerIndex(), bytesRead)) {
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof ByteBuf) { return ByteBufUtil.equals(this, (ByteBuf) obj); } return false; }
@Override public boolean equals(Object o) { return this == o || (o instanceof ByteBuf && ByteBufUtil.equals(this, (ByteBuf) o)); }
/** * Returns {@code true} if and only if the two specified buffers are * identical to each other as described in {@link ByteBuf#equals(Object)}. * This method is useful when implementing a new buffer type. */ public static boolean equals(ByteBuf bufferA, ByteBuf bufferB) { final int aLen = bufferA.readableBytes(); if (aLen != bufferB.readableBytes()) { return false; } return equals(bufferA, bufferA.readerIndex(), bufferB, bufferB.readerIndex(), aLen); }