本文整理匯總了Java中org.jboss.netty.handler.codec.http.HttpResponseEncoder類的典型用法代碼示例。如果您正苦於以下問題:Java HttpResponseEncoder類的具體用法?Java HttpResponseEncoder怎麽用?Java HttpResponseEncoder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
HttpResponseEncoder類屬於org.jboss.netty.handler.codec.http包,在下文中一共展示了HttpResponseEncoder類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getPipeline
import org.jboss.netty.handler.codec.http.HttpResponseEncoder; //導入依賴的package包/類
@Override
public ChannelPipeline getPipeline() throws Exception {
ChannelPipeline pipeline = Channels.pipeline();
if (sslFactory != null) {
pipeline.addLast("ssl", new SslHandler(sslFactory.createSSLEngine()));
}
pipeline.addLast("decoder", new HttpRequestDecoder());
pipeline.addLast("aggregator", new HttpChunkAggregator(1 << 16));
pipeline.addLast("encoder", new HttpResponseEncoder());
pipeline.addLast("chunking", new ChunkedWriteHandler());
pipeline.addLast("shuffle", SHUFFLE);
return pipeline;
// TODO factor security manager into pipeline
// TODO factor out encode/decode to permit binary shuffle
// TODO factor out decode of index to permit alt. models
}
示例2: startHttpServer
import org.jboss.netty.handler.codec.http.HttpResponseEncoder; //導入依賴的package包/類
private ServerBootstrap startHttpServer(int port,
final Token<DelegationTokenIdentifier> token, final URI url) {
ServerBootstrap bootstrap = new ServerBootstrap(
new NioServerSocketChannelFactory(Executors.newCachedThreadPool(),
Executors.newCachedThreadPool()));
bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
@Override
public ChannelPipeline getPipeline() throws Exception {
return Channels.pipeline(new HttpRequestDecoder(),
new HttpChunkAggregator(65536), new HttpResponseEncoder(),
new CredentialsLogicHandler(token, url.toString()));
}
});
bootstrap.bind(new InetSocketAddress("localhost", port));
return bootstrap;
}
示例3: getPipeline
import org.jboss.netty.handler.codec.http.HttpResponseEncoder; //導入依賴的package包/類
@Override
public ChannelPipeline getPipeline() throws Exception {
HttpRequestHandler httpRequestHandler = new HttpRequestHandler();
httpRequestHandler.setSettings(settings);
httpRequestHandler.setApplicationContext(applicationContext);
ChannelPipeline pipeline = Channels.pipeline();
if (settings.getKeepAliveTimeout() > 0) {
pipeline.addLast("idle", new IdleStateHandler(timer, 0, 0, settings.getKeepAliveTimeout()));
pipeline.addLast("timeout", httpTimeoutHandler);
}
pipeline.addLast("decoder", new HttpRequestDecoder());
pipeline.addLast("encoder", new HttpResponseEncoder());
pipeline.addLast("handler", httpRequestHandler);
return pipeline;
}
示例4: getPipeline
import org.jboss.netty.handler.codec.http.HttpResponseEncoder; //導入依賴的package包/類
@Override
public ChannelPipeline getPipeline() throws Exception {
RemoteRequestHandler remoteRequestHandler = new RemoteRequestHandler();
remoteRequestHandler.setSettings(settings);
remoteRequestHandler.setApplicationContext(applicationContext);
ChannelPipeline pipeline = Channels.pipeline();
if (settings.getKeepAliveTimeout() > 0) {
pipeline.addLast("idle", new IdleStateHandler(timer, 0, 0, settings.getKeepAliveTimeout()));
pipeline.addLast("timeout", httpTimeoutHandler);
}
pipeline.addLast("decoder", new HttpRequestDecoder());
pipeline.addLast("encoder", new HttpResponseEncoder());
pipeline.addLast("handler", remoteRequestHandler);
return pipeline;
}
示例5: getPipeline
import org.jboss.netty.handler.codec.http.HttpResponseEncoder; //導入依賴的package包/類
@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;
}
示例6: initServer
import org.jboss.netty.handler.codec.http.HttpResponseEncoder; //導入依賴的package包/類
/**
* Start WebImageViewer.
* @param fsimage the fsimage to load.
* @throws IOException if fail to load the fsimage.
*/
@VisibleForTesting
public void initServer(String fsimage) throws IOException {
FSImageLoader loader = FSImageLoader.load(fsimage);
ChannelPipeline pipeline = Channels.pipeline();
pipeline.addLast("channelTracker", new SimpleChannelUpstreamHandler() {
@Override
public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e)
throws Exception {
allChannels.add(e.getChannel());
}
});
pipeline.addLast("httpDecoder", new HttpRequestDecoder());
pipeline.addLast("requestHandler", new FSImageHandler(loader));
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("httpEncoder", new HttpResponseEncoder());
bootstrap.setPipeline(pipeline);
channel = bootstrap.bind(address);
allChannels.add(channel);
address = (InetSocketAddress) channel.getLocalAddress();
LOG.info("WebImageViewer started. Listening on " + address.toString()
+ ". Press Ctrl+C to stop the viewer.");
}
示例7: getPipeline
import org.jboss.netty.handler.codec.http.HttpResponseEncoder; //導入依賴的package包/類
@Override
public ChannelPipeline getPipeline() throws Exception {
ChannelPipeline pipeline = Channels.pipeline();
if (sslFactory != null) {
pipeline.addLast("ssl", new SslHandler(sslFactory.createSSLEngine()));
}
pipeline.addLast("decoder", new HttpRequestDecoder());
pipeline.addLast("aggregator", new HttpChunkAggregator(1 << 16));
pipeline.addLast("encoder", new HttpResponseEncoder());
pipeline.addLast("chunking", new ChunkedWriteHandler());
pipeline.addLast("shuffle", SHUFFLE);
pipeline.addLast("idle", idleStateHandler);
pipeline.addLast(TIMEOUT_HANDLER, new TimeoutHandler());
return pipeline;
// TODO factor security manager into pipeline
// TODO factor out encode/decode to permit binary shuffle
// TODO factor out decode of index to permit alt. models
}
示例8: getPipeline
import org.jboss.netty.handler.codec.http.HttpResponseEncoder; //導入依賴的package包/類
public ChannelPipeline getPipeline() throws Exception {
// Create a default pipeline implementation.
ChannelPipeline pipeline = pipeline();
// Uncomment the following line if you want HTTPS
// SSLEngine engine =
// SecureChatSslContextFactory.getServerContext().createSSLEngine();
// engine.setUseClientMode(false);
// pipeline.addLast("ssl", new SslHandler(engine));
pipeline.addLast("decoder", new HttpRequestDecoder());
//pipeline.addLast("aggregator", new HttpChunkAggregator(65536));
pipeline.addLast("encoder", new HttpResponseEncoder());
pipeline.addLast("chunkedWriter", new ChunkedWriteHandler());
//pipeline.addLast("deflater", new HttpContentCompressor());
pipeline.addLast("handler", new HttpDataServerHandler(ret));
return pipeline;
}
示例9: getPipeline
import org.jboss.netty.handler.codec.http.HttpResponseEncoder; //導入依賴的package包/類
public ChannelPipeline getPipeline() throws Exception {
// Create a default pipeline implementation.
ChannelPipeline pipeline = pipeline();
// Uncomment the following line if you want HTTPS
// SSLEngine engine =
// SecureChatSslContextFactory.getServerContext().createSSLEngine();
// engine.setUseClientMode(false);
// pipeline.addLast("ssl", new SslHandler(engine));
pipeline.addLast("decoder", new HttpRequestDecoder());
//pipeline.addLast("aggregator", new HttpChunkAggregator(65536));
pipeline.addLast("encoder", new HttpResponseEncoder());
pipeline.addLast("chunkedWriter", new ChunkedWriteHandler());
pipeline.addLast("deflater", new HttpContentCompressor());
pipeline.addLast("handler", new HttpDataServerHandler(userName, appId));
return pipeline;
}
示例10: getPipeline
import org.jboss.netty.handler.codec.http.HttpResponseEncoder; //導入依賴的package包/類
@Override
public ChannelPipeline getPipeline( ) throws Exception
{
ChannelPipeline pipeline = pipeline( ) ;
//Descomentar se for usar HTTPS
// SSLEngine engine = SecureChatSslContextFactory.getServerContext( ).createSSLEngine( ) ;
// engine.setUseClientMode( false ) ;
// pipeline.addLast( "ssl", new SslHandler( engine ) ) ;
pipeline.addLast( "decoder", new HttpRequestDecoder( ) ) ;
pipeline.addLast( "aggregator", new HttpChunkAggregator( 65536 ) ) ;
pipeline.addLast( "encoder", new HttpResponseEncoder( ) ) ;
pipeline.addLast( "chunkedWriter", new ChunkedWriteHandler( ) ) ;
pipeline.addLast( "handler", new BettaUdpFileServerHandler( ) ) ;
return pipeline ;
}
示例11: getPipeline
import org.jboss.netty.handler.codec.http.HttpResponseEncoder; //導入依賴的package包/類
public ChannelPipeline getPipeline() throws Exception {
Integer max = Integer.valueOf(Play.configuration.getProperty("play.netty.maxContentLength", "-1"));
ChannelPipeline pipeline = pipeline();
PlayHandler playHandler = new PlayHandler();
pipeline.addLast("flashPolicy", new FlashPolicyHandler());
pipeline.addLast("decoder", new HttpRequestDecoder());
pipeline.addLast("aggregator", new StreamChunkAggregator(max));
pipeline.addLast("encoder", new HttpResponseEncoder());
pipeline.addLast("chunkedWriter", playHandler.chunkedWriteHandler);
pipeline.addLast("handler", playHandler);
return pipeline;
}
示例12: run
import org.jboss.netty.handler.codec.http.HttpResponseEncoder; //導入依賴的package包/類
public void run() {
// Configure the server.
ServerBootstrap bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedThreadPool()));
// Set up the event pipeline factory.
bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
public ChannelPipeline getPipeline() {
ChannelPipeline pipeline = Channels.pipeline();
pipeline.addLast("decoder", new HttpRequestDecoder());
pipeline.addLast("aggregator", new HttpChunkAggregator(65536));
pipeline.addLast("encoder", new HttpResponseEncoder());
pipeline.addLast("handler", new HttpHandler());
return pipeline;
}
});
bootstrap.setOption("child.reuseAddress", true);
bootstrap.setOption("child.tcpNoDelay", true);
bootstrap.setOption("child.keepAlive", false);
// Bind and start to accept incoming connections.
bootstrap.bind(new InetSocketAddress(port));
}
示例13: getChannelPipelineFactory
import org.jboss.netty.handler.codec.http.HttpResponseEncoder; //導入依賴的package包/類
/**
* handle http
*/
protected ChannelPipelineFactory getChannelPipelineFactory(){
return new ChannelPipelineFactory(){
public ChannelPipeline getPipeline()
throws Exception{
// Create a default pipeline implementation.
ChannelPipeline pipeline = Channels.pipeline();
pipeline.addLast("decoder", new HttpRequestDecoder());
pipeline.addLast("encoder", new HttpResponseEncoder());
pipeline.addLast("channel", channel);
return pipeline;
}
};
}
示例14: getChannelPipelineFactory
import org.jboss.netty.handler.codec.http.HttpResponseEncoder; //導入依賴的package包/類
protected ChannelPipelineFactory getChannelPipelineFactory(){
return new ChannelPipelineFactory(){
public ChannelPipeline getPipeline()
throws Exception{
// Create a default pipeline implementation.
ChannelPipeline pipeline = Channels.pipeline();
pipeline.addLast("decoder", new HttpRequestDecoder());
pipeline.addLast("encoder", new HttpResponseEncoder());
pipeline.addLast("channel", channel);
return pipeline;
}
};
}
示例15: getPipeline
import org.jboss.netty.handler.codec.http.HttpResponseEncoder; //導入依賴的package包/類
@Override
public ChannelPipeline getPipeline() {
ChannelPipeline pipeline = Channels.pipeline();
// decoders
pipeline.addLast("decoder", new HttpRequestDecoder());
pipeline.addLast("chunker", new HttpChunkAggregator(MAX_REQUEST_LENGTH));
// encoders
pipeline.addLast("encoder", new HttpResponseEncoder());
// handler
pipeline.addLast("timeout", new IdleStateHandler(timer, NetworkConstants.IDLE_TIME, 0, 0));
pipeline.addLast("handler", handler);
return pipeline;
}