use of org.jboss.netty.handler.codec.http.HttpChunkAggregator in project weave by continuuity.
the class TrackerService method startUp.
@Override
protected void startUp() throws Exception {
Executor bossThreads = Executors.newFixedThreadPool(NUM_BOSS_THREADS, new ThreadFactoryBuilder().setDaemon(true).setNameFormat("boss-thread").build());
Executor workerThreads = Executors.newCachedThreadPool(new ThreadFactoryBuilder().setDaemon(true).setNameFormat("worker-thread#%d").build());
ChannelFactory factory = new NioServerSocketChannelFactory(bossThreads, workerThreads);
bootstrap = new ServerBootstrap(factory);
bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
public ChannelPipeline getPipeline() {
ChannelPipeline pipeline = Channels.pipeline();
pipeline.addLast("decoder", new HttpRequestDecoder());
pipeline.addLast("aggregator", new HttpChunkAggregator(MAX_INPUT_SIZE));
pipeline.addLast("encoder", new HttpResponseEncoder());
pipeline.addLast("compressor", new HttpContentCompressor());
pipeline.addLast("handler", new ReportHandler(resourceReport));
return pipeline;
}
});
Channel channel = bootstrap.bind(new InetSocketAddress(host, 0));
bindAddress = (InetSocketAddress) channel.getLocalAddress();
url = URI.create(String.format("http://%s:%d", host, bindAddress.getPort())).resolve(TrackerService.PATH).toURL();
channelGroup.add(channel);
}
use of org.jboss.netty.handler.codec.http.HttpChunkAggregator in project graylog2-server by Graylog2.
the class HttpTransport method getBaseChannelHandlers.
@Override
protected LinkedHashMap<String, Callable<? extends ChannelHandler>> getBaseChannelHandlers(MessageInput input) {
final LinkedHashMap<String, Callable<? extends ChannelHandler>> baseChannelHandlers = super.getBaseChannelHandlers(input);
if (idleWriterTimeout > 0) {
// Install read timeout handler to close idle connections after a timeout.
// This avoids dangling HTTP connections when the HTTP client does not close the connection properly.
// For details see: https://github.com/Graylog2/graylog2-server/issues/3223#issuecomment-270350500
baseChannelHandlers.put("read-timeout-handler", () -> new ReadTimeoutHandler(timer, idleWriterTimeout, TimeUnit.SECONDS));
}
baseChannelHandlers.put("decoder", () -> new HttpRequestDecoder(DEFAULT_MAX_INITIAL_LINE_LENGTH, DEFAULT_MAX_HEADER_SIZE, maxChunkSize));
baseChannelHandlers.put("aggregator", () -> new HttpChunkAggregator(maxChunkSize));
baseChannelHandlers.put("encoder", HttpResponseEncoder::new);
baseChannelHandlers.put("decompressor", HttpContentDecompressor::new);
return baseChannelHandlers;
}
use of org.jboss.netty.handler.codec.http.HttpChunkAggregator in project camel by apache.
the class HttpServerSharedPipelineFactory method getPipeline.
@Override
public ChannelPipeline getPipeline() throws Exception {
// Create a default pipeline implementation.
ChannelPipeline pipeline = Channels.pipeline();
SslHandler sslHandler = configureServerSSLOnDemand();
if (sslHandler != null) {
LOG.debug("Server SSL handler configured and added as an interceptor against the ChannelPipeline: {}", sslHandler);
pipeline.addLast("ssl", sslHandler);
}
pipeline.addLast("decoder", new HttpRequestDecoder(4096, configuration.getMaxHeaderSize(), 8192));
if (configuration.isChunked()) {
pipeline.addLast("aggregator", new HttpChunkAggregator(configuration.getChunkedMaxContentLength()));
}
pipeline.addLast("encoder", new HttpResponseEncoder());
if (configuration.isCompression()) {
pipeline.addLast("deflater", new HttpContentCompressor());
}
pipeline.addLast("handler", channelFactory.getChannelHandler());
return pipeline;
}
use of org.jboss.netty.handler.codec.http.HttpChunkAggregator in project sockjs-netty by cgbystrom.
the class StressTestServer method start.
public void start() throws Exception {
final JmxReporter reporter = JmxReporter.forRegistry(registry).build();
final ServiceRouter router = new ServiceRouter();
reporter.start();
router.setMetricRegistry(registry);
Service echoService = new Service("/stresstest", new SessionCallbackFactory() {
@Override
public StressTestSession getSession(String id) throws Exception {
return new StressTestSession();
}
});
router.registerService(echoService);
bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
@Override
public ChannelPipeline getPipeline() throws Exception {
ChannelPipeline pipeline = pipeline();
pipeline.addLast("decoder", new HttpRequestDecoder());
// Required for WS handshaker or else NPE.
pipeline.addLast("chunkAggregator", new HttpChunkAggregator(130 * 1024));
pipeline.addLast("encoder", new HttpResponseEncoder());
pipeline.addLast("preflight", new PreflightHandler());
pipeline.addLast("router", router);
return pipeline;
}
});
bootstrap.bind(new LocalAddress(port));
}
use of org.jboss.netty.handler.codec.http.HttpChunkAggregator in project sockjs-netty by cgbystrom.
the class TestServer method main.
public static void main(String[] args) {
Logger rootLogger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
LoggerContext loggerContext = rootLogger.getLoggerContext();
loggerContext.reset();
PatternLayoutEncoder encoder = new PatternLayoutEncoder();
encoder.setContext(loggerContext);
encoder.setPattern("%-5level %-20class{0}: %message%n");
encoder.start();
ConsoleAppender<ILoggingEvent> appender = new ConsoleAppender<ILoggingEvent>();
appender.setContext(loggerContext);
appender.setEncoder(encoder);
appender.start();
rootLogger.addAppender(appender);
InternalLoggerFactory.setDefaultFactory(new Slf4JLoggerFactory());
ServerBootstrap bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedThreadPool()));
final MetricRegistry registry = new MetricRegistry();
final JmxReporter reporter = JmxReporter.forRegistry(registry).build();
reporter.start();
final ServiceRouter router = new ServiceRouter();
router.setMetricRegistry(registry);
router.registerService(new Service("/disabled_websocket_echo", new DisabledWebSocketEchoSession()));
router.registerService(new Service("/close", new CloseSession()));
router.registerService(new Service("/amplify", new AmplifySession()));
router.registerService(new Service("/broadcast", new SessionCallbackFactory() {
@Override
public BroadcastSession getSession(String id) throws Exception {
return new BroadcastSession();
}
}));
Service echoService = new Service("/echo", new SessionCallbackFactory() {
@Override
public EchoSession getSession(String id) throws Exception {
return new EchoSession();
}
});
echoService.setMaxResponseSize(4096);
router.registerService(echoService);
Service cookieNeededEcho = new Service("/cookie_needed_echo", new EchoSession());
cookieNeededEcho.setMaxResponseSize(4096);
cookieNeededEcho.setCookieNeeded(true);
router.registerService(cookieNeededEcho);
bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
@Override
public ChannelPipeline getPipeline() throws Exception {
ChannelPipeline pipeline = pipeline();
pipeline.addLast("decoder", new HttpRequestDecoder());
// Required for WS handshaker or else NPE.
pipeline.addLast("chunkAggregator", new HttpChunkAggregator(130 * 1024));
pipeline.addLast("encoder", new HttpResponseEncoder());
pipeline.addLast("preflight", new PreflightHandler());
pipeline.addLast("router", router);
return pipeline;
}
});
bootstrap.bind(new InetSocketAddress(8090));
System.out.println("Server running..");
}
Aggregations