优化http注释
This commit is contained in:
@@ -5,10 +5,10 @@
|
||||
*/
|
||||
package org.redkale.net.http;
|
||||
|
||||
import java.nio.channels.CompletionHandler;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Function;
|
||||
import java.nio.channels.*;
|
||||
import java.security.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.function.*;
|
||||
import org.redkale.annotation.ConstructorParameters;
|
||||
import org.redkale.asm.*;
|
||||
import static org.redkale.asm.Opcodes.*;
|
||||
@@ -41,7 +41,7 @@ public class HttpContext extends Context {
|
||||
|
||||
protected final AnyValue rpcAuthenticatorConfig;
|
||||
|
||||
//所有Servlet方法都不需要读取http-header且RestBaseServlet不是自定义HttpServlet且不存在HttpFilter的情况下,lazyHeaders=true
|
||||
//所有Servlet方法都不需要读取http-header且RestBaseServlet不是自定义HttpServlet且不存在HttpFilter、WebSocket的情况下,lazyHeaders=true
|
||||
protected boolean lazyHeaders; //存在动态改值
|
||||
|
||||
Function<WebSocket, WebSocketWriteIOThread> webSocketWriterIOThreadFunc;
|
||||
|
||||
@@ -5,17 +5,17 @@
|
||||
*/
|
||||
package org.redkale.net.http;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.concurrent.locks.*;
|
||||
import java.util.function.*;
|
||||
import java.util.logging.*;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.regex.*;
|
||||
import java.util.stream.*;
|
||||
import org.redkale.net.*;
|
||||
import org.redkale.net.Filter;
|
||||
import org.redkale.net.http.Rest.RestDynSourceType;
|
||||
import org.redkale.service.Service;
|
||||
import org.redkale.service.*;
|
||||
import org.redkale.util.AnyValue.DefaultAnyValue;
|
||||
import org.redkale.util.*;
|
||||
|
||||
@@ -400,7 +400,7 @@ public class HttpDispatcherServlet extends DispatcherServlet<String, HttpContext
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.lazyHeaders && !Rest.isSimpleRestDyn(servlet)) {
|
||||
if (this.lazyHeaders && (!Rest.isSimpleRestDyn(servlet) || servlet instanceof WebSocketServlet)) {
|
||||
this.lazyHeaders = false;
|
||||
if (context != null) {
|
||||
context.lazyHeaders = this.lazyHeaders; //启动后运行过程中执行addServlet
|
||||
@@ -451,9 +451,9 @@ public class HttpDispatcherServlet extends DispatcherServlet<String, HttpContext
|
||||
putMapping(mappingPath, servlet);
|
||||
}
|
||||
if (servlet instanceof WebSocketServlet) {
|
||||
Map<String, WebSocketServlet> newmappings = new HashMap<>(wsmappings);
|
||||
newmappings.put(mappingPath, (WebSocketServlet) servlet);
|
||||
this.wsmappings = newmappings;
|
||||
Map<String, WebSocketServlet> newMappings = new HashMap<>(wsmappings);
|
||||
newMappings.put(mappingPath, (WebSocketServlet) servlet);
|
||||
this.wsmappings = newMappings;
|
||||
}
|
||||
}
|
||||
if (this.allMapStrings.containsKey(mappingPath)) {
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
*/
|
||||
package org.redkale.net.http;
|
||||
|
||||
import org.redkale.convert.Convert;
|
||||
import org.redkale.util.AnyValue;
|
||||
import org.redkale.convert.*;
|
||||
import org.redkale.util.*;
|
||||
|
||||
/**
|
||||
* HTTP输出引擎的基类 <br>
|
||||
@@ -28,8 +28,11 @@ import org.redkale.util.AnyValue;
|
||||
*/
|
||||
public interface HttpRender {
|
||||
|
||||
public void init(HttpContext context, AnyValue config);
|
||||
default void init(HttpContext context, AnyValue config) {
|
||||
}
|
||||
|
||||
public void renderTo(HttpRequest request, HttpResponse response, Convert convert, HttpScope scope);
|
||||
|
||||
default void destroy(HttpContext context, AnyValue config) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,17 +6,17 @@
|
||||
package org.redkale.net.http;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.annotation.*;
|
||||
import java.net.*;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.*;
|
||||
import java.nio.charset.*;
|
||||
import java.util.*;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.logging.Level;
|
||||
import java.util.function.*;
|
||||
import java.util.logging.*;
|
||||
import org.redkale.annotation.Comment;
|
||||
import org.redkale.convert.*;
|
||||
import org.redkale.convert.json.JsonConvert;
|
||||
import org.redkale.net.Request;
|
||||
import org.redkale.convert.json.*;
|
||||
import org.redkale.net.*;
|
||||
import org.redkale.util.*;
|
||||
|
||||
/**
|
||||
@@ -322,7 +322,7 @@ public class HttpRequest extends Request<HttpContext> {
|
||||
this.respConvertType = httplast.respConvertType;
|
||||
this.respConvert = httplast.respConvert;
|
||||
this.headerLength = httplast.headerLength;
|
||||
this.headerHalfLen = httplast.headerLength;
|
||||
this.headerHalfLen = httplast.headerHalfLen;
|
||||
this.headerBytes = httplast.headerBytes;
|
||||
this.headerParsed = httplast.headerParsed;
|
||||
this.headers.putAll(httplast.headers);
|
||||
@@ -448,12 +448,6 @@ public class HttpRequest extends Request<HttpContext> {
|
||||
}
|
||||
}
|
||||
|
||||
// @Override
|
||||
// protected int readBody(ByteBuffer buffer, int length) {
|
||||
// int len = buffer.remaining();
|
||||
// array.put(buffer, len);
|
||||
// return len;
|
||||
// }
|
||||
//解析 GET /xxx HTTP/1.1
|
||||
private int readMethodLine(final ByteBuffer buf) {
|
||||
final ByteBuffer buffer = buf;
|
||||
@@ -1438,12 +1432,18 @@ public class HttpRequest extends Request<HttpContext> {
|
||||
+ (this.frombody ? (", \r\n frombody: " + this.frombody) : "")
|
||||
+ (this.reqConvertType != null ? (", \r\n reqConvertType: " + this.reqConvertType) : "")
|
||||
+ (this.respConvertType != null ? (", \r\n respConvertType: " + this.respConvertType) : "")
|
||||
+ ", \r\n currentUserid: " + (this.currentUserid == CURRUSERID_NIL ? null : this.currentUserid) + ", \r\n remoteAddr: " + this.getRemoteAddr()
|
||||
+ ", \r\n cookies: " + this.cookie + ", \r\n contentType: " + this.contentType
|
||||
+ ", \r\n protocol: " + this.protocol + ", \r\n host: " + this.host
|
||||
+ ", \r\n contentLength: " + this.contentLength + ", \r\n bodyLength: " + this.array.length()
|
||||
+ (this.currentUserid != CURRUSERID_NIL ? (", \r\n currentUserid: " + (this.currentUserid == CURRUSERID_NIL ? null : this.currentUserid)) : "")
|
||||
+ (this.getRemoteAddr() != null ? (", \r\n remoteAddr: " + this.getRemoteAddr()) : "")
|
||||
+ (this.cookie != null ? (", \r\n cookies: " + this.cookie) : "")
|
||||
+ (this.contentType != null ? (", \r\n contentType: " + this.contentType) : "")
|
||||
+ (this.protocol != null ? (", \r\n protocol: " + this.protocol) : "")
|
||||
+ (this.host != null ? (", \r\n host: " + this.host) : "")
|
||||
+ (this.contentLength >= 0 ? (", \r\n contentLength: " + this.contentLength) : "")
|
||||
+ (this.array.length() > 0 ? (", \r\n bodyLength: " + this.array.length()) : "")
|
||||
+ (this.boundary || this.array.isEmpty() ? "" : (", \r\n bodyContent: " + (this.respConvertType == null || this.respConvertType == ConvertType.JSON ? this.getBodyUTF8() : Arrays.toString(getBody()))))
|
||||
+ ", \r\n params: " + toMapString(this.params, 4) + ", \r\n header: " + toMapString(this.headers, 4) + "\r\n}"; //this.headers.toString(4)
|
||||
+ ", \r\n params: " + toMapString(this.params, 4)
|
||||
+ ", \r\n header: " + toMapString(this.headers, 4)
|
||||
+ "\r\n}"; //this.headers.toString(4)
|
||||
}
|
||||
|
||||
private static CharSequence toMapString(Map<String, String> map, int indent) {
|
||||
|
||||
@@ -5,24 +5,24 @@
|
||||
*/
|
||||
package org.redkale.net.http;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.HttpCookie;
|
||||
import java.lang.reflect.*;
|
||||
import java.net.*;
|
||||
import java.text.*;
|
||||
import java.time.ZoneId;
|
||||
import java.time.*;
|
||||
import static java.time.format.DateTimeFormatter.RFC_1123_DATE_TIME;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.LongAdder;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.logging.Level;
|
||||
import org.redkale.boot.Application;
|
||||
import java.util.concurrent.atomic.*;
|
||||
import java.util.concurrent.locks.*;
|
||||
import java.util.function.*;
|
||||
import java.util.logging.*;
|
||||
import org.redkale.boot.*;
|
||||
import org.redkale.mq.*;
|
||||
import org.redkale.net.Server;
|
||||
import org.redkale.net.*;
|
||||
import org.redkale.net.http.HttpContext.HttpContextConfig;
|
||||
import org.redkale.net.http.HttpResponse.HttpResponseConfig;
|
||||
import org.redkale.net.sncp.Sncp;
|
||||
import org.redkale.service.Service;
|
||||
import org.redkale.net.sncp.*;
|
||||
import org.redkale.service.*;
|
||||
import org.redkale.util.*;
|
||||
|
||||
/**
|
||||
@@ -90,6 +90,11 @@ public class HttpServer extends Server<String, HttpContext, HttpRequest, HttpRes
|
||||
if (context.rpcAuthenticator != null) {
|
||||
context.rpcAuthenticator.destroy(context.rpcAuthenticatorConfig);
|
||||
}
|
||||
HttpResponseConfig respConf = this.respConfig;
|
||||
HttpRender httpRender = respConf.httpRender;
|
||||
if (httpRender != null) {
|
||||
httpRender.destroy(context, respConf.renderConfig);
|
||||
}
|
||||
}
|
||||
|
||||
public List<HttpServlet> getHttpServlets() {
|
||||
|
||||
@@ -5,18 +5,18 @@
|
||||
*/
|
||||
package org.redkale.net.http;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.io.*;
|
||||
import java.lang.annotation.*;
|
||||
import java.lang.reflect.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.logging.Level;
|
||||
import org.redkale.annotation.NonBlocking;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.function.*;
|
||||
import java.util.logging.*;
|
||||
import org.redkale.annotation.*;
|
||||
import static org.redkale.asm.ClassWriter.COMPUTE_FRAMES;
|
||||
import org.redkale.asm.*;
|
||||
import static org.redkale.asm.Opcodes.*;
|
||||
import org.redkale.boot.Application;
|
||||
import org.redkale.boot.*;
|
||||
import org.redkale.net.*;
|
||||
import org.redkale.util.*;
|
||||
|
||||
@@ -36,7 +36,7 @@ public class HttpServlet extends Servlet<HttpContext, HttpRequest, HttpResponse>
|
||||
//@Deprecated(since = "2.8.0")
|
||||
//public static final int RET_METHOD_ERROR = 1200_0002;
|
||||
//
|
||||
String _actionSimpleMappingUrl; //只给HttpActionServlet使用,_actionSimpleMappingUrl不能包含正则表达式,比如 /json /createRecord, 不能是 /user/**
|
||||
String _actionSimpleMappingUrl; //只给HttpActionServlet使用,_actionSimpleMappingUrl不能包含正则表达式,比如: /json、/createRecord, 不能是/user/**
|
||||
|
||||
String _prefix = ""; //当前HttpServlet的path前缀
|
||||
|
||||
@@ -269,7 +269,7 @@ public class HttpServlet extends Servlet<HttpContext, HttpRequest, HttpResponse>
|
||||
preExecute(request, response);
|
||||
}
|
||||
|
||||
static Boolean isNonBlocking(Class<?> servletClass) {
|
||||
static Boolean isNonBlocking(Class<? extends HttpServlet> servletClass) {
|
||||
Class clz = servletClass;
|
||||
Boolean preNonBlocking = null;
|
||||
Boolean authNonBlocking = null;
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
package org.redkale.net.http;
|
||||
|
||||
import java.net.*;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.CompletionHandler;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.nio.*;
|
||||
import java.nio.channels.*;
|
||||
import java.nio.charset.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import org.redkale.net.*;
|
||||
import static org.redkale.net.http.HttpRequest.parseHeaderName;
|
||||
import org.redkale.util.*;
|
||||
@@ -20,7 +20,7 @@ import org.redkale.util.*;
|
||||
* 1、使用HTTPS;<br>
|
||||
* 2、上传下载文件;<br>
|
||||
* 3、返回超大响应包;<br>
|
||||
* 类似JDK11的 java.net.http.HttpSimpleClient <br>
|
||||
* 类似JDK11的 java.net.http.HttpClient <br>
|
||||
*
|
||||
* <p>
|
||||
* 详情见: https://redkale.org
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
package org.redkale.service;
|
||||
|
||||
import java.util.concurrent.*;
|
||||
import org.redkale.annotation.Resource;
|
||||
import org.redkale.boot.Application;
|
||||
import org.redkale.net.WorkThread;
|
||||
import org.redkale.annotation.*;
|
||||
import org.redkale.boot.*;
|
||||
import org.redkale.net.*;
|
||||
import org.redkale.util.*;
|
||||
|
||||
/**
|
||||
@@ -31,11 +31,6 @@ public abstract class AbstractService implements Service {
|
||||
return serviceName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前Service类的原始Service类型, 由于Service会动态重载,所以getClass()得到的不是原始Service类型
|
||||
*
|
||||
* @return Class
|
||||
*/
|
||||
protected Class serviceType() {
|
||||
return serviceType;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user