This commit is contained in:
redkale
2024-09-13 07:47:26 +08:00
parent aa3a00a40f
commit a757504877
2 changed files with 59 additions and 18 deletions

View File

@@ -344,12 +344,11 @@ public abstract class Response<C extends Context, R extends Request<C>> {
}
this.recycleListener = null;
}
boolean completed = request.completed;
if (request.keepAlive && (request.pipelineIndex == 0 || request.pipelineCompleted)) {
AsyncConnection conn = removeChannel();
if (conn != null && conn.protocolCodec != null) {
this.responseConsumer.accept(this);
if (!completed) {
if (!request.completed) {
conn.readRegister(conn.protocolCodec);
this.readRegistered = true;
}

View File

@@ -76,6 +76,10 @@ public final class ByteArray implements ByteTuple {
return true;
}
public ByteBuffer wrapByteBuffer() {
return ByteBuffer.wrap(content, 0, count);
}
public ReadableByteChannel toChannel() {
final byte[] bytes = getBytes();
final AtomicInteger offset = new AtomicInteger();
@@ -893,22 +897,6 @@ public final class ByteArray implements ByteTuple {
return put((byte) value);
}
/**
* 写入一个byte值
*
* @param value byte值
* @return ByteArray
*/
public ByteArray put(byte value) {
if (count >= content.length - 1) {
byte[] ns = new byte[content.length + 8];
System.arraycopy(content, 0, ns, 0, count);
this.content = ns;
}
content[count++] = value;
return this;
}
/**
* 写入一个byte值
*
@@ -942,6 +930,60 @@ public final class ByteArray implements ByteTuple {
return this;
}
/**
* 写入一个byte值
*
* @param value byte值
* @return ByteArray
*/
public ByteArray put(byte value) {
if (count >= content.length - 1) {
byte[] ns = new byte[content.length + 8];
System.arraycopy(content, 0, ns, 0, count);
this.content = ns;
}
content[count++] = value;
return this;
}
/**
* 写入两个byte值
*
* @param value1 byte值
* @param value2 byte值
* @return ByteArray
*/
public ByteArray put(byte value1, byte value2) {
if (count >= content.length - 2) {
byte[] ns = new byte[content.length + 8];
System.arraycopy(content, 0, ns, 0, count);
this.content = ns;
}
content[count++] = value1;
content[count++] = value2;
return this;
}
/**
* 写入三个byte值
*
* @param value1 byte值
* @param value2 byte值
* @param value3 byte值
* @return ByteArray
*/
public ByteArray put(byte value1, byte value2, byte value3) {
if (count >= content.length - 3) {
byte[] ns = new byte[content.length + 8];
System.arraycopy(content, 0, ns, 0, count);
this.content = ns;
}
content[count++] = value1;
content[count++] = value2;
content[count++] = value3;
return this;
}
/**
* 写入一组byte值
*