Response
This commit is contained in:
@@ -254,6 +254,10 @@ public abstract class Response<C extends Context, R extends Request<C>> {
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public C getContext() {
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否已关闭
|
* 是否已关闭
|
||||||
*
|
*
|
||||||
@@ -345,6 +349,10 @@ public abstract class Response<C extends Context, R extends Request<C>> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final void finish(ByteTuple array) {
|
||||||
|
finish(false, array.content(), array.offset(), array.length());
|
||||||
|
}
|
||||||
|
|
||||||
public final void finish(byte[] bs) {
|
public final void finish(byte[] bs) {
|
||||||
finish(false, bs, 0, bs.length);
|
finish(false, bs, 0, bs.length);
|
||||||
}
|
}
|
||||||
@@ -353,34 +361,30 @@ public abstract class Response<C extends Context, R extends Request<C>> {
|
|||||||
finish(false, bs, offset, length);
|
finish(false, bs, offset, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void finish(ByteTuple array) {
|
public final void finish(boolean kill, ByteTuple array) {
|
||||||
finish(false, array.content(), array.offset(), array.length());
|
finish(kill, array.content(), array.offset(), array.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void finish(boolean kill, byte[] bs) {
|
public final void finish(boolean kill, byte[] bs) {
|
||||||
finish(kill, bs, 0, bs.length);
|
finish(kill, bs, 0, bs.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void finish(boolean kill, ByteTuple array) {
|
|
||||||
finish(kill, array.content(), array.offset(), array.length());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void finish(boolean kill, byte[] bs, int offset, int length) {
|
public void finish(boolean kill, byte[] bs, int offset, int length) {
|
||||||
if (kill) {
|
if (kill) {
|
||||||
refuseAlive();
|
refuseAlive();
|
||||||
}
|
}
|
||||||
if (request.pipelineIndex > 0) {
|
int pipelineIndex = request.pipelineIndex;
|
||||||
boolean allCompleted =
|
if (pipelineIndex > 0) {
|
||||||
this.channel.appendPipeline(request.pipelineIndex, request.pipelineCount, bs, offset, length);
|
boolean completed = this.channel.appendPipeline(pipelineIndex, request.pipelineCount, bs, offset, length);
|
||||||
if (allCompleted) {
|
if (completed) { // pipeline全部完成
|
||||||
request.pipelineCompleted = true;
|
request.pipelineCompleted = true;
|
||||||
this.channel.writePipelineInIOThread(this.finishBytesIOThreadHandler);
|
this.channel.writePipelineInIOThread(this.finishBytesIOThreadHandler);
|
||||||
} else {
|
} else { // 数据缓存在channel中
|
||||||
removeChannel();
|
removeChannel();
|
||||||
this.responseConsumer.accept(this);
|
this.responseConsumer.accept(this);
|
||||||
}
|
}
|
||||||
} else if (this.channel.hasPipelineData()) {
|
} else if (this.channel.hasPipelineData()) {
|
||||||
this.channel.appendPipeline(request.pipelineIndex, request.pipelineCount, bs, offset, length);
|
this.channel.appendPipeline(pipelineIndex, request.pipelineCount, bs, offset, length);
|
||||||
this.channel.writePipelineInIOThread(this.finishBytesIOThreadHandler);
|
this.channel.writePipelineInIOThread(this.finishBytesIOThreadHandler);
|
||||||
} else {
|
} else {
|
||||||
ByteBuffer buffer = this.writeBuffer;
|
ByteBuffer buffer = this.writeBuffer;
|
||||||
@@ -394,8 +398,4 @@ public abstract class Response<C extends Context, R extends Request<C>> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public C getContext() {
|
|
||||||
return context;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user