mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-03-29 12:38:26 +03:00
[FIX][EXP] Фикс встроенного файлсервера.
This commit is contained in:
parent
80925b6366
commit
068e2c6d64
1 changed files with 3 additions and 2 deletions
|
@ -55,6 +55,7 @@ public class FileServerHandler extends SimpleChannelInboundHandler<FullHttpReque
|
||||||
public static final String HTTP_DATE_GMT_TIMEZONE = "GMT";
|
public static final String HTTP_DATE_GMT_TIMEZONE = "GMT";
|
||||||
public static final String READ = "r";
|
public static final String READ = "r";
|
||||||
public static final int HTTP_CACHE_SECONDS = 60;
|
public static final int HTTP_CACHE_SECONDS = 60;
|
||||||
|
private static final boolean OLD_ALGO = Boolean.parseBoolean(System.getProperty("launcher.fileserver.oldalgo", "false"));
|
||||||
private final Path base;
|
private final Path base;
|
||||||
private final boolean fullOut;
|
private final boolean fullOut;
|
||||||
|
|
||||||
|
@ -143,11 +144,12 @@ public void channelRead0(ChannelHandlerContext ctx, FullHttpRequest request) thr
|
||||||
// Write the content.
|
// Write the content.
|
||||||
ChannelFuture sendFileFuture;
|
ChannelFuture sendFileFuture;
|
||||||
ChannelFuture lastContentFuture;
|
ChannelFuture lastContentFuture;
|
||||||
if (ctx.pipeline().get(SslHandler.class) == null) {
|
if (OLD_ALGO) {
|
||||||
sendFileFuture =
|
sendFileFuture =
|
||||||
ctx.write(new DefaultFileRegion(raf.getChannel(), 0, fileLength), ctx.newProgressivePromise());
|
ctx.write(new DefaultFileRegion(raf.getChannel(), 0, fileLength), ctx.newProgressivePromise());
|
||||||
// Write the end marker.
|
// Write the end marker.
|
||||||
lastContentFuture = ctx.writeAndFlush(LastHttpContent.EMPTY_LAST_CONTENT);
|
lastContentFuture = ctx.writeAndFlush(LastHttpContent.EMPTY_LAST_CONTENT);
|
||||||
|
lastContentFuture.addListener(new ClosingChannelFutureListener(raf));
|
||||||
} else {
|
} else {
|
||||||
sendFileFuture =
|
sendFileFuture =
|
||||||
ctx.writeAndFlush(new HttpChunkedInput(new ChunkedFile(raf, 0, fileLength, 8192)),
|
ctx.writeAndFlush(new HttpChunkedInput(new ChunkedFile(raf, 0, fileLength, 8192)),
|
||||||
|
@ -158,7 +160,6 @@ public void channelRead0(ChannelHandlerContext ctx, FullHttpRequest request) thr
|
||||||
|
|
||||||
// Decide whether to close the connection or not.
|
// Decide whether to close the connection or not.
|
||||||
if (!HttpUtil.isKeepAlive(request)) {
|
if (!HttpUtil.isKeepAlive(request)) {
|
||||||
lastContentFuture.addListener(new ClosingChannelFutureListener(raf));
|
|
||||||
lastContentFuture.addListener(ChannelFutureListener.CLOSE);
|
lastContentFuture.addListener(ChannelFutureListener.CLOSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue