This commit is contained in:
@@ -30,6 +30,8 @@ public abstract class Response<C extends Context, R extends Request<C>> {
|
|||||||
|
|
||||||
protected AsyncConnection channel;
|
protected AsyncConnection channel;
|
||||||
|
|
||||||
|
protected ByteBuffer moredata; //pipeline模式
|
||||||
|
|
||||||
protected ByteBuffer writeHeadBuffer;
|
protected ByteBuffer writeHeadBuffer;
|
||||||
|
|
||||||
protected ByteBuffer writeBodyBuffer;
|
protected ByteBuffer writeBodyBuffer;
|
||||||
@@ -167,6 +169,12 @@ public abstract class Response<C extends Context, R extends Request<C>> {
|
|||||||
return ch;
|
return ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected ByteBuffer removeMoredata() {
|
||||||
|
ByteBuffer rs = this.moredata;
|
||||||
|
this.moredata = null;
|
||||||
|
return rs;
|
||||||
|
}
|
||||||
|
|
||||||
protected void prepare() {
|
protected void prepare() {
|
||||||
inited = true;
|
inited = true;
|
||||||
}
|
}
|
||||||
@@ -176,6 +184,7 @@ public abstract class Response<C extends Context, R extends Request<C>> {
|
|||||||
this.output = null;
|
this.output = null;
|
||||||
this.filter = null;
|
this.filter = null;
|
||||||
this.servlet = null;
|
this.servlet = null;
|
||||||
|
this.moredata = null;
|
||||||
request.recycle();
|
request.recycle();
|
||||||
if (channel != null) {
|
if (channel != null) {
|
||||||
channel.dispose();
|
channel.dispose();
|
||||||
|
|||||||
@@ -26,23 +26,15 @@ import org.redkale.util.*;
|
|||||||
*/
|
*/
|
||||||
public class HttpContext extends Context {
|
public class HttpContext extends Context {
|
||||||
|
|
||||||
//是否开启pipeline
|
|
||||||
protected final boolean pipeline;
|
|
||||||
|
|
||||||
protected final SecureRandom random = new SecureRandom();
|
protected final SecureRandom random = new SecureRandom();
|
||||||
|
|
||||||
protected final ConcurrentHashMap<Class, Creator> asyncHandlerCreators = new ConcurrentHashMap<>();
|
protected final ConcurrentHashMap<Class, Creator> asyncHandlerCreators = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
public HttpContext(HttpContextConfig config) {
|
public HttpContext(HttpContextConfig config) {
|
||||||
super(config);
|
super(config);
|
||||||
this.pipeline = config.pipeline;
|
|
||||||
random.setSeed(Math.abs(System.nanoTime()));
|
random.setSeed(Math.abs(System.nanoTime()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean isPipeline() {
|
|
||||||
return pipeline;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String createSessionid() {
|
protected String createSessionid() {
|
||||||
byte[] bytes = new byte[16];
|
byte[] bytes = new byte[16];
|
||||||
random.nextBytes(bytes);
|
random.nextBytes(bytes);
|
||||||
@@ -187,7 +179,5 @@ public class HttpContext extends Context {
|
|||||||
|
|
||||||
public static class HttpContextConfig extends ContextConfig {
|
public static class HttpContextConfig extends ContextConfig {
|
||||||
|
|
||||||
//是否开启pipeline
|
|
||||||
public boolean pipeline;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -166,9 +166,9 @@ public class HttpRequest extends Request<HttpContext> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
array.clear();
|
array.clear();
|
||||||
if (!context.isPipeline()) {
|
|
||||||
if (buffer.hasRemaining()) array.write(buffer, buffer.remaining());
|
if (buffer.hasRemaining()) array.write(buffer, buffer.remaining());
|
||||||
}
|
|
||||||
if (this.contentType != null && this.contentType.contains("boundary=")) {
|
if (this.contentType != null && this.contentType.contains("boundary=")) {
|
||||||
this.boundary = true;
|
this.boundary = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -320,9 +320,7 @@ public class HttpServer extends Server<String, HttpContext, HttpRequest, HttpRes
|
|||||||
String jsonContentType = null;
|
String jsonContentType = null;
|
||||||
HttpCookie defaultCookie = null;
|
HttpCookie defaultCookie = null;
|
||||||
String remoteAddrHeader = null;
|
String remoteAddrHeader = null;
|
||||||
boolean pipeline = false;
|
|
||||||
if (config != null) {
|
if (config != null) {
|
||||||
pipeline = config.getBoolValue("pipeline", false);
|
|
||||||
AnyValue reqs = config == null ? null : config.getAnyValue("request");
|
AnyValue reqs = config == null ? null : config.getAnyValue("request");
|
||||||
if (reqs != null) {
|
if (reqs != null) {
|
||||||
AnyValue raddr = reqs.getAnyValue("remoteaddr");
|
AnyValue raddr = reqs.getAnyValue("remoteaddr");
|
||||||
@@ -442,7 +440,6 @@ public class HttpServer extends Server<String, HttpContext, HttpRequest, HttpRes
|
|||||||
contextConfig.logger = this.logger;
|
contextConfig.logger = this.logger;
|
||||||
contextConfig.executor = this.executor;
|
contextConfig.executor = this.executor;
|
||||||
contextConfig.sslContext = this.sslContext;
|
contextConfig.sslContext = this.sslContext;
|
||||||
contextConfig.pipeline = pipeline;
|
|
||||||
contextConfig.bufferCapacity = rcapacity;
|
contextConfig.bufferCapacity = rcapacity;
|
||||||
contextConfig.bufferPool = bufferPool;
|
contextConfig.bufferPool = bufferPool;
|
||||||
contextConfig.responsePool = responsePool;
|
contextConfig.responsePool = responsePool;
|
||||||
|
|||||||
Reference in New Issue
Block a user