Response
This commit is contained in:
@@ -187,8 +187,10 @@ class ProtocolCodec implements CompletionHandler<Integer, ByteBuffer> {
|
|||||||
}
|
}
|
||||||
channel.setReadBuffer(buffer.clear());
|
channel.setReadBuffer(buffer.clear());
|
||||||
context.executeDispatch(request, response);
|
context.executeDispatch(request, response);
|
||||||
|
if (!response.readRegistered) {
|
||||||
channel.readRegister(this);
|
channel.readRegister(this);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else { // rs > 0
|
} else { // rs > 0
|
||||||
channel.setReadBuffer(buffer);
|
channel.setReadBuffer(buffer);
|
||||||
channel.read(readHandler.prepare(request, response, pipelineIndex, lastReq));
|
channel.read(readHandler.prepare(request, response, pipelineIndex, lastReq));
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ public abstract class Response<C extends Context, R extends Request<C>> {
|
|||||||
|
|
||||||
protected boolean inNonBlocking = true;
|
protected boolean inNonBlocking = true;
|
||||||
|
|
||||||
|
protected boolean readRegistered;
|
||||||
|
|
||||||
// 输出的结果对象
|
// 输出的结果对象
|
||||||
protected Object output;
|
protected Object output;
|
||||||
|
|
||||||
@@ -139,6 +141,7 @@ public abstract class Response<C extends Context, R extends Request<C>> {
|
|||||||
protected void prepare() {
|
protected void prepare() {
|
||||||
inited = true;
|
inited = true;
|
||||||
inNonBlocking = true;
|
inNonBlocking = true;
|
||||||
|
readRegistered = false;
|
||||||
request.prepare();
|
request.prepare();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -348,6 +351,7 @@ public abstract class Response<C extends Context, R extends Request<C>> {
|
|||||||
this.responseConsumer.accept(this);
|
this.responseConsumer.accept(this);
|
||||||
if (!completed) {
|
if (!completed) {
|
||||||
conn.readRegister(conn.protocolCodec);
|
conn.readRegister(conn.protocolCodec);
|
||||||
|
this.readRegistered = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Supplier<Response> poolSupplier = this.responseSupplier;
|
Supplier<Response> poolSupplier = this.responseSupplier;
|
||||||
@@ -356,6 +360,7 @@ public abstract class Response<C extends Context, R extends Request<C>> {
|
|||||||
new ProtocolCodec(context, poolSupplier, poolConsumer, conn)
|
new ProtocolCodec(context, poolSupplier, poolConsumer, conn)
|
||||||
.response(this)
|
.response(this)
|
||||||
.run(null);
|
.run(null);
|
||||||
|
this.readRegistered = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.responseConsumer.accept(this);
|
this.responseConsumer.accept(this);
|
||||||
|
|||||||
@@ -416,7 +416,7 @@ public class HttpRequest extends Request<HttpContext> {
|
|||||||
this.keepAlive = false;
|
this.keepAlive = false;
|
||||||
}
|
}
|
||||||
// completed=true时ProtocolCodec会继续读下一个request
|
// completed=true时ProtocolCodec会继续读下一个request
|
||||||
this.completed = !this.boundary && !maybews && this.headerParsed;
|
this.completed = !this.boundary && !maybews;
|
||||||
this.readState = READ_STATE_BODY;
|
this.readState = READ_STATE_BODY;
|
||||||
}
|
}
|
||||||
if (this.readState == READ_STATE_BODY) {
|
if (this.readState == READ_STATE_BODY) {
|
||||||
|
|||||||
Reference in New Issue
Block a user