This commit is contained in:
redkale
2024-09-12 08:44:38 +08:00
parent 2c39167025
commit c370c885e6
3 changed files with 9 additions and 2 deletions

View File

@@ -187,7 +187,9 @@ class ProtocolCodec implements CompletionHandler<Integer, ByteBuffer> {
}
channel.setReadBuffer(buffer.clear());
context.executeDispatch(request, response);
channel.readRegister(this);
if (!response.readRegistered) {
channel.readRegister(this);
}
}
} else { // rs > 0
channel.setReadBuffer(buffer);

View File

@@ -46,6 +46,8 @@ public abstract class Response<C extends Context, R extends Request<C>> {
protected boolean inNonBlocking = true;
protected boolean readRegistered;
// 输出的结果对象
protected Object output;
@@ -139,6 +141,7 @@ public abstract class Response<C extends Context, R extends Request<C>> {
protected void prepare() {
inited = true;
inNonBlocking = true;
readRegistered = false;
request.prepare();
}
@@ -348,6 +351,7 @@ public abstract class Response<C extends Context, R extends Request<C>> {
this.responseConsumer.accept(this);
if (!completed) {
conn.readRegister(conn.protocolCodec);
this.readRegistered = true;
}
} else {
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)
.response(this)
.run(null);
this.readRegistered = true;
}
} else {
this.responseConsumer.accept(this);

View File

@@ -416,7 +416,7 @@ public class HttpRequest extends Request<HttpContext> {
this.keepAlive = false;
}
// completed=true时ProtocolCodec会继续读下一个request
this.completed = !this.boundary && !maybews && this.headerParsed;
this.completed = !this.boundary && !maybews;
this.readState = READ_STATE_BODY;
}
if (this.readState == READ_STATE_BODY) {