Response
This commit is contained in:
@@ -344,12 +344,11 @@ public abstract class Response<C extends Context, R extends Request<C>> {
|
|||||||
}
|
}
|
||||||
this.recycleListener = null;
|
this.recycleListener = null;
|
||||||
}
|
}
|
||||||
boolean completed = request.completed;
|
|
||||||
if (request.keepAlive && (request.pipelineIndex == 0 || request.pipelineCompleted)) {
|
if (request.keepAlive && (request.pipelineIndex == 0 || request.pipelineCompleted)) {
|
||||||
AsyncConnection conn = removeChannel();
|
AsyncConnection conn = removeChannel();
|
||||||
if (conn != null && conn.protocolCodec != null) {
|
if (conn != null && conn.protocolCodec != null) {
|
||||||
this.responseConsumer.accept(this);
|
this.responseConsumer.accept(this);
|
||||||
if (!completed) {
|
if (!request.completed) {
|
||||||
conn.readRegister(conn.protocolCodec);
|
conn.readRegister(conn.protocolCodec);
|
||||||
this.readRegistered = true;
|
this.readRegistered = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,6 +76,10 @@ public final class ByteArray implements ByteTuple {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ByteBuffer wrapByteBuffer() {
|
||||||
|
return ByteBuffer.wrap(content, 0, count);
|
||||||
|
}
|
||||||
|
|
||||||
public ReadableByteChannel toChannel() {
|
public ReadableByteChannel toChannel() {
|
||||||
final byte[] bytes = getBytes();
|
final byte[] bytes = getBytes();
|
||||||
final AtomicInteger offset = new AtomicInteger();
|
final AtomicInteger offset = new AtomicInteger();
|
||||||
@@ -893,22 +897,6 @@ public final class ByteArray implements ByteTuple {
|
|||||||
return put((byte) value);
|
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值
|
* 写入一个byte值
|
||||||
*
|
*
|
||||||
@@ -942,6 +930,60 @@ public final class ByteArray implements ByteTuple {
|
|||||||
return this;
|
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值
|
* 写入一组byte值
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user