当前位置: 首页>>代码示例>>Java>>正文


Java ChunkedInput类代码示例

本文整理汇总了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);
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:39,代码来源:HttpChunkedInputTest.java

示例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();
  }
}
 
开发者ID:HubSpot,项目名称:NioSmtpClient,代码行数:16,代码来源:SmtpSession.java

示例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);
	}
}
 
开发者ID:reactor,项目名称:reactor-netty,代码行数:11,代码来源:NettyOutbound.java

示例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());
				}
			}));
}
 
开发者ID:reactor,项目名称:reactor-netty,代码行数:29,代码来源:NettyOutbound.java

示例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);
	}
}
 
开发者ID:reactor,项目名称:reactor-netty,代码行数:11,代码来源:HttpOperations.java

示例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);
	}
}
 
开发者ID:reactor,项目名称:reactor-netty,代码行数:10,代码来源:NettyOutboundTest.java

示例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);
			}
		});
		*/
}
 
开发者ID:Gadreel,项目名称:divconq,代码行数:16,代码来源:HttpContext.java

示例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;
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:9,代码来源:HttpChunkedInput.java

示例9: create

import io.netty.handler.stream.ChunkedInput; //导入依赖的package包/类
static ChunkedInput<HttpContent> create(ChunkSource chunkSource) throws IOException {
    return new ChunkSourceChunkedInput(chunkSource);
}
 
开发者ID:glowroot,项目名称:glowroot,代码行数:4,代码来源:ChunkedInputs.java

示例10: createZipFileDownload

import io.netty.handler.stream.ChunkedInput; //导入依赖的package包/类
static ChunkedInput<HttpContent> createZipFileDownload(ChunkSource chunkSource, String fileName)
        throws IOException {
    return new ZipFileChunkedInput(chunkSource, fileName);
}
 
开发者ID:glowroot,项目名称:glowroot,代码行数:5,代码来源:ChunkedInputs.java

示例11: HttpChunkedBodyEncoder

import io.netty.handler.stream.ChunkedInput; //导入依赖的package包/类
public HttpChunkedBodyEncoder( ChunkedInput<ByteBuf> chunkedBody )
{
    this.chunkedBody = chunkedBody;
}
 
开发者ID:werval,项目名称:werval,代码行数:5,代码来源:HttpChunkedBodyEncoder.java

示例12: send

import io.netty.handler.stream.ChunkedInput; //导入依赖的package包/类
public void send(ChunkedInput<HttpContent> content) {
	this.innerctx.send(content);
}
 
开发者ID:Gadreel,项目名称:divconq,代码行数:4,代码来源:WebContext.java

示例13: send

import io.netty.handler.stream.ChunkedInput; //导入依赖的package包/类
@Override
public void send(ChunkedInput<HttpContent> content) {
	System.out.println("unexpected send chunk");
}
 
开发者ID:Gadreel,项目名称:divconq,代码行数:5,代码来源:EmailInnerContext.java

示例14: open

import io.netty.handler.stream.ChunkedInput; //导入依赖的package包/类
@Override
public ChunkedInput<ByteBuf> open() throws IOException {
    return new EmptyChunkedInput<ByteBuf>();
}
 
开发者ID:justinsb,项目名称:cloudata,代码行数:5,代码来源:EmptyFsFile.java

示例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);
}
 
开发者ID:justinsb,项目名称:cloudata,代码行数:5,代码来源:SimpleFsFile.java


注:本文中的io.netty.handler.stream.ChunkedInput类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。