public void verifyChannelPipeline(ChannelPipeline pipeline, String scheme) throws IOException, GeneralSecurityException { boolean sslHandlerConfigured = isSslHandlerConfigured(pipeline); if (isSecure(scheme)) { if (!sslHandlerConfigured) pipeline.addFirst(SSL_HANDLER, new SslInitializer(this)); } else if (sslHandlerConfigured) pipeline.remove(SSL_HANDLER); }
@Override public void write(Channel channel, NettyResponseFuture<?> future, AsyncHttpClientConfig config) throws IOException { final RandomAccessFile raf = new RandomAccessFile(file, "r"); try { ChannelFuture writeFuture; if (ChannelManager.isSslHandlerConfigured(channel.getPipeline()) || nettyConfig.isDisableZeroCopy()) { writeFuture = channel.write(new ChunkedFile(raf, offset, raf.length(), nettyConfig.getChunkedFileChunkSize())); } else { final FileRegion region = new OptimizedFileRegion(raf, offset, raf.length()); writeFuture = channel.write(region); } writeFuture.addListener(new ProgressListener(config, future.getAsyncHandler(), future, false) { public void operationComplete(ChannelFuture cf) { closeSilently(raf); super.operationComplete(cf); } }); } catch (IOException ex) { closeSilently(raf); throw ex; } } }
if (body instanceof RandomAccessBody && !ChannelManager.isSslHandlerConfigured(channel.getPipeline()) && !nettyConfig.isDisableZeroCopy()) { msg = new BodyFileRegion((RandomAccessBody) body);
public void upgradeProtocol(ChannelPipeline pipeline, String scheme, String host, int port) throws IOException, GeneralSecurityException { if (pipeline.get(HTTP_HANDLER) != null) pipeline.remove(HTTP_HANDLER); if (isSecure(scheme)) if (isSslHandlerConfigured(pipeline)) { pipeline.addAfter(SSL_HANDLER, HTTP_HANDLER, newHttpClientCodec()); } else { pipeline.addFirst(HTTP_HANDLER, newHttpClientCodec()); pipeline.addFirst(SSL_HANDLER, createSslHandler(host, port)); } else pipeline.addFirst(HTTP_HANDLER, newHttpClientCodec()); if (isWebSocket(scheme)) { pipeline.addAfter(HTTP_PROCESSOR, WS_PROCESSOR, wsProcessor); pipeline.remove(HTTP_PROCESSOR); } }
public void verifyChannelPipeline(ChannelPipeline pipeline, String scheme) throws IOException, GeneralSecurityException { boolean sslHandlerConfigured = isSslHandlerConfigured(pipeline); if (isSecure(scheme)) { if (!sslHandlerConfigured) pipeline.addFirst(SSL_HANDLER, new SslInitializer(this)); } else if (sslHandlerConfigured) pipeline.remove(SSL_HANDLER); }
@Override public void write(Channel channel, NettyResponseFuture<?> future, AsyncHttpClientConfig config) throws IOException { final RandomAccessFile raf = new RandomAccessFile(file, "r"); try { ChannelFuture writeFuture; if (ChannelManager.isSslHandlerConfigured(channel.getPipeline()) || nettyConfig.isDisableZeroCopy()) { writeFuture = channel.write(new ChunkedFile(raf, offset, raf.length(), nettyConfig.getChunkedFileChunkSize())); } else { final FileRegion region = new OptimizedFileRegion(raf, offset, raf.length()); writeFuture = channel.write(region); } writeFuture.addListener(new ProgressListener(config, future.getAsyncHandler(), future, false) { public void operationComplete(ChannelFuture cf) { closeSilently(raf); super.operationComplete(cf); } }); } catch (IOException ex) { closeSilently(raf); throw ex; } } }
@Override public void write(final Channel channel, NettyResponseFuture<?> future, AsyncHttpClientConfig config) throws IOException { Object msg; if (body instanceof RandomAccessBody && !ChannelManager.isSslHandlerConfigured(channel.getPipeline()) && !nettyConfig.isDisableZeroCopy()) { msg = new BodyFileRegion((RandomAccessBody) body); } else { msg = new BodyChunkedInput(body); BodyGenerator bg = future.getRequest().getBodyGenerator(); if (bg instanceof FeedableBodyGenerator) { FeedableBodyGenerator.class.cast(bg).setListener(new FeedListener() { @Override public void onContentAdded() { channel.getPipeline().get(ChunkedWriteHandler.class).resumeTransfer(); } }); } } channel.write(msg).addListener(new ProgressListener(config, future.getAsyncHandler(), future, false) { public void operationComplete(ChannelFuture cf) { closeSilently(body); super.operationComplete(cf); } }); } }
public void upgradeProtocol(ChannelPipeline pipeline, String scheme, String host, int port) throws IOException, GeneralSecurityException { if (pipeline.get(HTTP_HANDLER) != null) pipeline.remove(HTTP_HANDLER); if (isSecure(scheme)) if (isSslHandlerConfigured(pipeline)){ pipeline.addAfter(SSL_HANDLER, HTTP_HANDLER, newHttpClientCodec()); } else { pipeline.addFirst(HTTP_HANDLER, newHttpClientCodec()); pipeline.addFirst(SSL_HANDLER, createSslHandler(host, port)); } else pipeline.addFirst(HTTP_HANDLER, newHttpClientCodec()); if (isWebSocket(scheme)) pipeline.replace(HTTP_PROCESSOR, WS_PROCESSOR, wsProcessor); }