本文整理汇总了Java中io.netty.handler.stream.ChunkedInput类的典型用法代码示例。如果您正苦于以下问题:Java ChunkedInput类的具体用法?Java ChunkedInput怎么用?Java ChunkedInput使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ChunkedInput类属于io.netty.handler.stream包,在下文中一共展示了ChunkedInput类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: check
import io.netty.handler.stream.ChunkedInput; //导入依赖的package包/类
private static void check(ChunkedInput<?>... inputs) {
EmbeddedChannel ch = new EmbeddedChannel(new ChunkedWriteHandler());
for (ChunkedInput<?> input : inputs) {
ch.writeOutbound(input);
}
assertTrue(ch.finish());
int i = 0;
int read = 0;
HttpContent lastHttpContent = null;
for (;;) {
HttpContent httpContent = (HttpContent) ch.readOutbound();
if (httpContent == null) {
break;
}
if (lastHttpContent != null) {
assertTrue("Chunk must be DefaultHttpContent", lastHttpContent instanceof DefaultHttpContent);
}
ByteBuf buffer = httpContent.content();
while (buffer.isReadable()) {
assertEquals(BYTES[i++], buffer.readByte());
read++;
if (i == BYTES.length) {
i = 0;
}
}
buffer.release();
// Save last chunk
lastHttpContent = httpContent;
}
assertEquals(BYTES.length * inputs.length, read);
assertSame("Last chunk must be DefaultLastHttpContent", LastHttpContent.EMPTY_LAST_CONTENT, lastHttpContent);
}
示例2: objectToString
import io.netty.handler.stream.ChunkedInput; //导入依赖的package包/类
private static String objectToString(Object o) {
if (o instanceof SmtpRequest) {
SmtpRequest request = (SmtpRequest) o;
if (request.command().equals(AUTH_COMMAND)) {
return "<redacted-auth-command>";
} else {
return String.format("%s %s", request.command().name(), Joiner.on(" ").join(request.parameters()));
}
} else if (o instanceof SmtpContent || o instanceof ByteBuf || o instanceof ChunkedInput) {
return "[CONTENT]";
} else {
return o.toString();
}
}
示例3: chunkFile
import io.netty.handler.stream.ChunkedInput; //导入依赖的package包/类
@Override
public ChunkedInput<ByteBuf> chunkFile(FileChannel fileChannel) {
try {
//TODO tune the chunk size
return new ChunkedNioFile(fileChannel, 1024);
}
catch (IOException e) {
throw Exceptions.propagate(e);
}
}
示例4: sendFileChunked
import io.netty.handler.stream.ChunkedInput; //导入依赖的package包/类
default NettyOutbound sendFileChunked(Path file, long position, long count) {
Objects.requireNonNull(file);
final FileChunkedStrategy strategy = getFileChunkedStrategy();
final boolean needChunkedWriteHandler = context().channel().pipeline().get(NettyPipeline.ChunkedWriter) == null;
if (needChunkedWriteHandler) {
strategy.preparePipeline(context());
}
return then(Mono.using(() -> FileChannel.open(file, StandardOpenOption.READ),
fc -> {
try {
ChunkedInput<?> message = strategy.chunkFile(fc);
return FutureMono.from(context().channel().writeAndFlush(message));
}
catch (Exception e) {
return Mono.error(e);
}
},
fc -> {
try {
fc.close();
}
catch (IOException ioe) {/*IGNORE*/}
finally {
strategy.cleanupPipeline(context());
}
}));
}
示例5: chunkFile
import io.netty.handler.stream.ChunkedInput; //导入依赖的package包/类
@Override
public ChunkedInput<HttpContent> chunkFile(FileChannel fileChannel) {
try {
//TODO tune the chunk size
return new HttpChunkedInput(new ChunkedNioFile(fileChannel, 1024));
}
catch (IOException e) {
throw Exceptions.propagate(e);
}
}
示例6: chunkFile
import io.netty.handler.stream.ChunkedInput; //导入依赖的package包/类
@Override
public ChunkedInput<ByteBuf> chunkFile(FileChannel fileChannel) {
try {
return new ChunkedNioFile(fileChannel, 1024);
}
catch (IOException e) {
throw Exceptions.propagate(e);
}
}
示例7: send
import io.netty.handler.stream.ChunkedInput; //导入依赖的package包/类
public void send(ChunkedInput<HttpContent> content) {
if (this.chan != null)
this.chan.write(content);
/* TODO we don't need this?
.addListener(new GenericFutureListener<Future<? super Void>>() {
@Override
public void operationComplete(Future<? super Void> future)
throws Exception {
//System.out.println("Sending an end");
//HttpContext.this.response.writeEnd(HttpContext.this.chan);
}
});
*/
}
示例8: HttpChunkedInput
import io.netty.handler.stream.ChunkedInput; //导入依赖的package包/类
/**
* Creates a new instance using the specified input.
* @param input {@link ChunkedInput} containing data to write
*/
public HttpChunkedInput(ChunkedInput<ByteBuf> input) {
this.input = input;
lastHttpContent = LastHttpContent.EMPTY_LAST_CONTENT;
}
示例9: create
import io.netty.handler.stream.ChunkedInput; //导入依赖的package包/类
static ChunkedInput<HttpContent> create(ChunkSource chunkSource) throws IOException {
return new ChunkSourceChunkedInput(chunkSource);
}
示例10: createZipFileDownload
import io.netty.handler.stream.ChunkedInput; //导入依赖的package包/类
static ChunkedInput<HttpContent> createZipFileDownload(ChunkSource chunkSource, String fileName)
throws IOException {
return new ZipFileChunkedInput(chunkSource, fileName);
}
示例11: HttpChunkedBodyEncoder
import io.netty.handler.stream.ChunkedInput; //导入依赖的package包/类
public HttpChunkedBodyEncoder( ChunkedInput<ByteBuf> chunkedBody )
{
this.chunkedBody = chunkedBody;
}
示例12: send
import io.netty.handler.stream.ChunkedInput; //导入依赖的package包/类
public void send(ChunkedInput<HttpContent> content) {
this.innerctx.send(content);
}
示例13: send
import io.netty.handler.stream.ChunkedInput; //导入依赖的package包/类
@Override
public void send(ChunkedInput<HttpContent> content) {
System.out.println("unexpected send chunk");
}
示例14: open
import io.netty.handler.stream.ChunkedInput; //导入依赖的package包/类
@Override
public ChunkedInput<ByteBuf> open() throws IOException {
return new EmptyChunkedInput<ByteBuf>();
}
示例15: open
import io.netty.handler.stream.ChunkedInput; //导入依赖的package包/类
@Override
public ChunkedInput<ByteBuf> open(Long from, Long to) throws IOException {
return new SliceByteInput(open(), from, to);
}