optimize: use jquery 2.1.4.min

refactor: DOA Contract
update: use doip sdk 1.0.2
optimize build.gradle
This commit is contained in:
CaiHQ 2021-12-21 17:48:31 +08:00
parent 05a8a992db
commit 826b256c85
3 changed files with 5 additions and 45 deletions

View File

@ -23,10 +23,7 @@ sourceSets {
}
dependencies {
api project (":common")
api 'io.netty:netty-all:4.1.52.Final'
api 'io.netty:netty-tcnative-boringssl-static:2.0.41.Final'
api 'org.apache.logging.log4j:log4j-core:2.15.0'
api 'org.apache.logging.log4j:log4j-api:2.15.0'
api 'com.google.code.gson:gson:2.8.8'
testImplementation 'junit:junit:4.13.2'

View File

@ -67,7 +67,6 @@ public class HttpResultCallback extends ResultCallback implements Runnable {
HttpUtil.setContentLength(response, bytes.length);
ChannelFuture future = ctxField.writeAndFlush(response);
future.addListener(ChannelFutureListener.CLOSE);
}
public void setDecodeBase64() {

View File

@ -11,18 +11,13 @@ import io.netty.handler.stream.ChunkedFile;
import java.io.File;
import java.io.FileFilter;
import java.io.RandomAccessFile;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.regex.Pattern;
import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1;
public class HttpFileHandleAdapter extends SimpleChannelInboundHandler<FullHttpRequest> {
private static final Pattern ALLOWED_FILE_NAME =
Pattern.compile("[A-Za-z0-9][-_A-Za-z0-9\\.]*");
private static final Pattern INSECURE_URI = Pattern.compile(".*[<>&\"].*");
FileFilter fileFilter;
private String location;
private final String location;
public HttpFileHandleAdapter(String path, FileFilter fileFilter) {
location = path;
@ -35,7 +30,7 @@ public class HttpFileHandleAdapter extends SimpleChannelInboundHandler<FullHttpR
HTTP_1_1,
status,
Unpooled.wrappedBuffer(
("Failure: " + status.toString() + "\r\n").getBytes()));
("Failure: " + status + "\r\n").getBytes()));
response.headers().set(HttpHeaderNames.CONTENT_TYPE, "text/plain; charset=UTF-8");
ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
}
@ -60,36 +55,6 @@ public class HttpFileHandleAdapter extends SimpleChannelInboundHandler<FullHttpR
ctx.writeAndFlush(response);
}
private String sanitizeUri(String uri) {
try {
// 使用JDK的URLDecoder进行解码
uri = URLDecoder.decode(uri, "UTF-8");
} catch (UnsupportedEncodingException e) {
try {
uri = URLDecoder.decode(uri, "ISO-8859-1");
} catch (UnsupportedEncodingException e1) {
throw new Error();
}
}
if (!uri.startsWith("/")) {
return null;
}
if (uri.contains("..")) {
return null;
}
// 将硬编码的文件路径
uri = uri.replace('/', File.separatorChar);
if (uri.contains(File.separator + '.')
|| uri.contains('.' + File.separator)
|| uri.startsWith(".")
|| uri.endsWith(".")
|| INSECURE_URI.matcher(uri).matches()) {
return null;
}
return System.getProperty("user.dir") + File.separator + uri;
}
@Override
protected void channelRead0(ChannelHandlerContext ctx, FullHttpRequest request)
throws Exception {
@ -137,9 +102,8 @@ public class HttpFileHandleAdapter extends SimpleChannelInboundHandler<FullHttpR
HttpUtil.setKeepAlive(response, true);
}
ctx.write(response);
// 同过netty的村可多File对象直接将文件写入到发送缓冲区最后为sendFileFeature增加GenericFeatureListener
// 如果发送完成打印Transfer complete
ctx.write(new ChunkedFile(file, 0, file.length(), 512 * 1024), ctx.newPromise());
// File对象直接将文件写入到发送缓冲区最后为sendFileFeature增加GenericFeatureListener
ctx.write(new ChunkedFile(file, 0, file.length(), 512 * 1024));
// 写入文件尾部
ChannelFuture future = ctx.writeAndFlush(LastHttpContent.EMPTY_LAST_CONTENT);
if (!keepAlive) {