Skip to content

confused about file wrapper depends on protocol #53

@HYisen

Description

@HYisen

if (ctx.pipeline().get(SslHandler.class) == null) {
ctx.write(new DefaultFileRegion(
file.getChannel(), 0, file.length()));
} else {
ctx.write(new ChunkedNioFile(file.getChannel()));
}

ctx.pipeline().get(SslHandler.class) == null checks whether HTTPS is enabled.
The difference between new DefaultFileRegion(file.getChannel(), 0, file.length()) and new ChunkedNioFile((file.getChannel())) is that the previous one would use zero-copy optimization, which is beneficial to performance if possible.
But how shall the protocol(TLS or not) determine the usage of optimization?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions