HttpContext.lazyHeader
This commit is contained in:
@@ -44,14 +44,14 @@ public class HttpContext extends Context {
|
|||||||
protected final AnyValue rpcAuthenticatorConfig;
|
protected final AnyValue rpcAuthenticatorConfig;
|
||||||
|
|
||||||
// 延迟解析header
|
// 延迟解析header
|
||||||
protected final boolean lazyHeaders;
|
protected final boolean lazyHeader;
|
||||||
|
|
||||||
// 不带通配符的mapping url的缓存对象
|
// 不带通配符的mapping url的缓存对象
|
||||||
final Map<ByteArray, String>[] uriPathCaches = new Map[100];
|
final Map<ByteArray, String>[] uriPathCaches = new Map[100];
|
||||||
|
|
||||||
public HttpContext(HttpContextConfig config) {
|
public HttpContext(HttpContextConfig config) {
|
||||||
super(config);
|
super(config);
|
||||||
this.lazyHeaders = config.lazyHeaders;
|
this.lazyHeader = config.lazyHeader;
|
||||||
this.remoteAddrHeader = config.remoteAddrHeader;
|
this.remoteAddrHeader = config.remoteAddrHeader;
|
||||||
this.remoteAddrHeaders = config.remoteAddrHeaders;
|
this.remoteAddrHeaders = config.remoteAddrHeaders;
|
||||||
this.localHeader = config.localHeader;
|
this.localHeader = config.localHeader;
|
||||||
@@ -234,7 +234,7 @@ public class HttpContext extends Context {
|
|||||||
|
|
||||||
public static class HttpContextConfig extends ContextConfig {
|
public static class HttpContextConfig extends ContextConfig {
|
||||||
// 是否延迟解析http-header
|
// 是否延迟解析http-header
|
||||||
public boolean lazyHeaders;
|
public boolean lazyHeader;
|
||||||
|
|
||||||
public String remoteAddrHeader;
|
public String remoteAddrHeader;
|
||||||
|
|
||||||
|
|||||||
@@ -374,7 +374,7 @@ public class HttpRequest extends Request<HttpContext> {
|
|||||||
this.headerBytes = httpLast.headerBytes;
|
this.headerBytes = httpLast.headerBytes;
|
||||||
this.headerParsed = httpLast.headerParsed;
|
this.headerParsed = httpLast.headerParsed;
|
||||||
this.headers.setAll(httpLast.headers);
|
this.headers.setAll(httpLast.headers);
|
||||||
} else if (context.lazyHeaders && getmethod) { // 非GET必须要读header,会有Content-Length
|
} else if (context.lazyHeader && getmethod) { // 非GET必须要读header,会有Content-Length
|
||||||
int rs = loadHeaderBytes(buffer);
|
int rs = loadHeaderBytes(buffer);
|
||||||
if (rs != 0) {
|
if (rs != 0) {
|
||||||
buffer.clear();
|
buffer.clear();
|
||||||
@@ -789,7 +789,7 @@ public class HttpRequest extends Request<HttpContext> {
|
|||||||
this.requestPath = toDecodeString(bytes, 0, bytes.length(), charset);
|
this.requestPath = toDecodeString(bytes, 0, bytes.length(), charset);
|
||||||
this.lastPathString = null;
|
this.lastPathString = null;
|
||||||
this.lastPathBytes = null;
|
this.lastPathBytes = null;
|
||||||
} else if (context.lazyHeaders) {
|
} else if (context.lazyHeader) {
|
||||||
byte[] lastURIBytes = lastPathBytes;
|
byte[] lastURIBytes = lastPathBytes;
|
||||||
if (lastURIBytes != null && lastURIBytes.length == size && bytes.deepEquals(lastURIBytes)) {
|
if (lastURIBytes != null && lastURIBytes.length == size && bytes.deepEquals(lastURIBytes)) {
|
||||||
this.requestPath = this.lastPathString;
|
this.requestPath = this.lastPathString;
|
||||||
@@ -1217,7 +1217,7 @@ public class HttpRequest extends Request<HttpContext> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected HttpRequest copyHeader() {
|
protected HttpRequest copyHeader() {
|
||||||
if (!PIPELINE_SAME_HEADERS || !context.lazyHeaders) {
|
if (!PIPELINE_SAME_HEADERS || !context.lazyHeader) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
HttpRequest req = new HttpRequest(context, this.body);
|
HttpRequest req = new HttpRequest(context, this.body);
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ public class HttpServer extends Server<String, HttpContext, HttpRequest, HttpRes
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String startExtLog() {
|
protected String startExtLog() {
|
||||||
return context.lazyHeaders ? ", lazyHeaders: true" : "";
|
return context.lazyHeader ? ", lazyHeader: true" : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<HttpServlet> getHttpServlets() {
|
public List<HttpServlet> getHttpServlets() {
|
||||||
@@ -595,7 +595,7 @@ public class HttpServer extends Server<String, HttpContext, HttpRequest, HttpRes
|
|||||||
contextConfig.remoteAddrHeader = addrHeader;
|
contextConfig.remoteAddrHeader = addrHeader;
|
||||||
contextConfig.remoteAddrHeaders = null;
|
contextConfig.remoteAddrHeaders = null;
|
||||||
}
|
}
|
||||||
contextConfig.lazyHeaders = lazyHeader;
|
contextConfig.lazyHeader = lazyHeader;
|
||||||
contextConfig.localHeader = localHeader;
|
contextConfig.localHeader = localHeader;
|
||||||
contextConfig.localParameter = localParameter;
|
contextConfig.localParameter = localParameter;
|
||||||
contextConfig.rpcAuthenticatorConfig = rpcAuthenticatorConfig;
|
contextConfig.rpcAuthenticatorConfig = rpcAuthenticatorConfig;
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ public final class Rest {
|
|||||||
@Retention(RUNTIME)
|
@Retention(RUNTIME)
|
||||||
public static @interface RestDyn {
|
public static @interface RestDyn {
|
||||||
|
|
||||||
// 是否不需要解析HttpHeader,对应HttpContext.lazyHeaders
|
// 是否不需要解析HttpHeader,对应HttpContext.lazyHeader
|
||||||
boolean simple() default false;
|
boolean simple() default false;
|
||||||
|
|
||||||
// 动态生成的类的子类需要关联一下,否则在运行过程中可能出现NoClassDefFoundError
|
// 动态生成的类的子类需要关联一下,否则在运行过程中可能出现NoClassDefFoundError
|
||||||
|
|||||||
Reference in New Issue
Block a user