use of org.apache.flink.shaded.netty4.io.netty.handler.stream.ChunkedWriteHandler in project netty by netty.
the class HttpCorsServerInitializer method initChannel.
@Override
public void initChannel(SocketChannel ch) {
CorsConfig corsConfig = CorsConfigBuilder.forAnyOrigin().allowNullOrigin().allowCredentials().build();
ChannelPipeline pipeline = ch.pipeline();
if (sslCtx != null) {
pipeline.addLast(sslCtx.newHandler(ch.alloc()));
}
pipeline.addLast(new HttpResponseEncoder());
pipeline.addLast(new HttpRequestDecoder());
pipeline.addLast(new HttpObjectAggregator(65536));
pipeline.addLast(new ChunkedWriteHandler());
pipeline.addLast(new CorsHandler(corsConfig));
pipeline.addLast(new OkResponseHandler());
}
use of org.apache.flink.shaded.netty4.io.netty.handler.stream.ChunkedWriteHandler in project netty by netty.
the class HttpStaticFileServerInitializer method initChannel.
@Override
public void initChannel(SocketChannel ch) {
ChannelPipeline pipeline = ch.pipeline();
if (sslCtx != null) {
pipeline.addLast(sslCtx.newHandler(ch.alloc()));
}
pipeline.addLast(new HttpServerCodec());
pipeline.addLast(new HttpObjectAggregator(65536));
pipeline.addLast(new ChunkedWriteHandler());
pipeline.addLast(new HttpStaticFileServerHandler());
}
use of org.apache.flink.shaded.netty4.io.netty.handler.stream.ChunkedWriteHandler in project jersey by jersey.
the class JerseyServerInitializer method configureClearText.
/**
* Configure the pipeline for a cleartext upgrade from HTTP to HTTP/2.
*/
private void configureClearText(SocketChannel ch) {
final ChannelPipeline p = ch.pipeline();
final HttpServerCodec sourceCodec = new HttpServerCodec();
p.addLast(sourceCodec);
p.addLast(new HttpServerUpgradeHandler(sourceCodec, new HttpServerUpgradeHandler.UpgradeCodecFactory() {
@Override
public HttpServerUpgradeHandler.UpgradeCodec newUpgradeCodec(CharSequence protocol) {
if (AsciiString.contentEquals(Http2CodecUtil.HTTP_UPGRADE_PROTOCOL_NAME, protocol)) {
return new Http2ServerUpgradeCodec(new Http2Codec(true, new JerseyHttp2ServerHandler(baseUri, container)));
} else {
return null;
}
}
}));
p.addLast(new SimpleChannelInboundHandler<HttpMessage>() {
@Override
protected void channelRead0(ChannelHandlerContext ctx, HttpMessage msg) throws Exception {
// If this handler is hit then no upgrade has been attempted and the client is just talking HTTP.
// "Directly talking: " + msg.protocolVersion() + " (no upgrade was attempted)");
ChannelPipeline pipeline = ctx.pipeline();
ChannelHandlerContext thisCtx = pipeline.context(this);
pipeline.addAfter(thisCtx.name(), null, new JerseyServerHandler(baseUri, container));
pipeline.replace(this, null, new ChunkedWriteHandler());
ctx.fireChannelRead(msg);
}
});
}
use of org.apache.flink.shaded.netty4.io.netty.handler.stream.ChunkedWriteHandler in project vert.x by eclipse.
the class NetServerImpl method initChannel.
@Override
protected void initChannel(ChannelPipeline pipeline) {
if (sslHelper.isSSL()) {
SslHandler sslHandler = sslHelper.createSslHandler(vertx);
pipeline.addLast("ssl", sslHandler);
}
if (logEnabled) {
pipeline.addLast("logging", new LoggingHandler());
}
if (sslHelper.isSSL()) {
// only add ChunkedWriteHandler when SSL is enabled otherwise it is not needed as FileRegion is used.
// For large file / sendfile support
pipeline.addLast("chunkedWriter", new ChunkedWriteHandler());
}
if (options.getIdleTimeout() > 0) {
pipeline.addLast("idle", new IdleStateHandler(0, 0, options.getIdleTimeout()));
}
}
use of org.apache.flink.shaded.netty4.io.netty.handler.stream.ChunkedWriteHandler in project neo4j by neo4j.
the class CatchupServer method start.
@Override
public synchronized void start() throws Throwable {
if (channel != null) {
return;
}
workerGroup = new NioEventLoopGroup(0, threadFactory);
ServerBootstrap bootstrap = new ServerBootstrap().group(workerGroup).channel(NioServerSocketChannel.class).localAddress(listenAddress.socketAddress()).childHandler(new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(SocketChannel ch) {
CatchupServerProtocol protocol = new CatchupServerProtocol();
ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast(new LengthFieldBasedFrameDecoder(Integer.MAX_VALUE, 0, 4, 0, 4));
pipeline.addLast(new LengthFieldPrepender(4));
pipeline.addLast(new VersionDecoder(logProvider));
pipeline.addLast(new VersionPrepender());
pipeline.addLast(new ResponseMessageTypeEncoder());
pipeline.addLast(new RequestMessageTypeEncoder());
pipeline.addLast(new TxPullResponseEncoder());
pipeline.addLast(new CoreSnapshotEncoder());
pipeline.addLast(new GetStoreIdResponseEncoder());
pipeline.addLast(new StoreCopyFinishedResponseEncoder());
pipeline.addLast(new TxStreamFinishedResponseEncoder());
pipeline.addLast(new FileChunkEncoder());
pipeline.addLast(new FileHeaderEncoder());
pipeline.addLast(new ServerMessageTypeHandler(protocol, logProvider));
pipeline.addLast(decoders(protocol));
pipeline.addLast(new TxPullRequestHandler(protocol, storeIdSupplier, dataSourceAvailabilitySupplier, transactionIdStoreSupplier, logicalTransactionStoreSupplier, txPullBatchSize, monitors, logProvider));
pipeline.addLast(new ChunkedWriteHandler());
pipeline.addLast(new GetStoreRequestHandler(protocol, dataSourceSupplier, checkPointerSupplier, fs, pageCache, logProvider, storeCopyCheckPointMutex));
pipeline.addLast(new GetStoreIdRequestHandler(protocol, storeIdSupplier));
if (coreState != null) {
pipeline.addLast(new CoreSnapshotRequestHandler(protocol, coreState));
}
pipeline.addLast(new ExceptionLoggingHandler(log));
pipeline.addLast(new ExceptionMonitoringHandler(monitors.newMonitor(ExceptionMonitoringHandler.Monitor.class, CatchupServer.class)));
pipeline.addLast(new ExceptionSwallowingHandler());
}
});
try {
channel = bootstrap.bind().syncUninterruptibly().channel();
} catch (Exception e) {
//noinspection ConstantConditions
if (e instanceof BindException) {
userLog.error("Address is already bound for setting: " + CausalClusteringSettings.transaction_listen_address + " with value: " + listenAddress);
log.error("Address is already bound for setting: " + CausalClusteringSettings.transaction_listen_address + " with value: " + listenAddress, e);
throw e;
}
}
}
Aggregations