mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +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 READ = "r";
|
||||
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 boolean fullOut;
|
||||
|
||||
|
@ -143,11 +144,12 @@ public void channelRead0(ChannelHandlerContext ctx, FullHttpRequest request) thr
|
|||
// Write the content.
|
||||
ChannelFuture sendFileFuture;
|
||||
ChannelFuture lastContentFuture;
|
||||
if (ctx.pipeline().get(SslHandler.class) == null) {
|
||||
if (OLD_ALGO) {
|
||||
sendFileFuture =
|
||||
ctx.write(new DefaultFileRegion(raf.getChannel(), 0, fileLength), ctx.newProgressivePromise());
|
||||
// Write the end marker.
|
||||
lastContentFuture = ctx.writeAndFlush(LastHttpContent.EMPTY_LAST_CONTENT);
|
||||
lastContentFuture.addListener(new ClosingChannelFutureListener(raf));
|
||||
} else {
|
||||
sendFileFuture =
|
||||
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.
|
||||
if (!HttpUtil.isKeepAlive(request)) {
|
||||
lastContentFuture.addListener(new ClosingChannelFutureListener(raf));
|
||||
lastContentFuture.addListener(ChannelFutureListener.CLOSE);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue