mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
Update FileServerHandler
This commit is contained in:
parent
e8126f565d
commit
788eb253f4
2 changed files with 23 additions and 1 deletions
|
@ -0,0 +1,22 @@
|
||||||
|
package ru.gravit.launchserver.fileserver;
|
||||||
|
|
||||||
|
import java.io.Closeable;
|
||||||
|
|
||||||
|
import io.netty.channel.ChannelFuture;
|
||||||
|
import io.netty.channel.ChannelFutureListener;
|
||||||
|
import ru.gravit.utils.helper.IOHelper;
|
||||||
|
|
||||||
|
public class ClosingChannelFutureListener implements ChannelFutureListener {
|
||||||
|
public final Closeable[] close;
|
||||||
|
|
||||||
|
public ClosingChannelFutureListener(Closeable... close) {
|
||||||
|
this.close = close;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void operationComplete(ChannelFuture future) {
|
||||||
|
for (Closeable cl : close) IOHelper.close(cl);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -169,7 +169,7 @@ public void operationComplete(ChannelProgressiveFuture future) {
|
||||||
|
|
||||||
// Decide whether to close the connection or not.
|
// Decide whether to close the connection or not.
|
||||||
if (!HttpUtil.isKeepAlive(request)) {
|
if (!HttpUtil.isKeepAlive(request)) {
|
||||||
// Close the connection when the whole content is written out.
|
lastContentFuture.addListener(new ClosingChannelFutureListener(raf));
|
||||||
lastContentFuture.addListener(ChannelFutureListener.CLOSE);
|
lastContentFuture.addListener(ChannelFutureListener.CLOSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue