List of usage examples for io.netty.handler.codec.http.cors CorsConfig withAnyOrigin
@Deprecated public static Builder withAnyOrigin()
From source file:com.phei.netty.nio.http.cors.HttpCorsServerInitializer.java
License:Apache License
@Override public void initChannel(SocketChannel ch) { CorsConfig corsConfig = CorsConfig.withAnyOrigin().build(); ChannelPipeline pipeline = ch.pipeline(); if (sslCtx != null) { pipeline.addLast(sslCtx.newHandler(ch.alloc())); }//from w w w. j a v a2 s .c o m 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()); }
From source file:com.topsec.bdc.platform.api.test.http.cors.HttpCorsServerInitializer.java
License:Apache License
@Override public void initChannel(SocketChannel ch) { CorsConfig corsConfig = CorsConfig.withAnyOrigin().build(); ChannelPipeline pipeline = ch.pipeline(); if (sslCtx != null) { pipeline.addLast(sslCtx.newHandler(ch.alloc())); }/*from ww w.ja v a2 s .com*/ 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()); }
From source file:edumsg.netty.EduMsgNettyServerInitializer.java
License:Open Source License
@Override protected void initChannel(SocketChannel arg0) { CorsConfig corsConfig = CorsConfig.withAnyOrigin() .allowedRequestHeaders("X-Requested-With", "Content-Type", "Content-Length") .allowedRequestMethods(HttpMethod.GET, HttpMethod.POST, HttpMethod.PUT, HttpMethod.DELETE, HttpMethod.OPTIONS)// ww w .java 2s . c o m .build(); ChannelPipeline p = arg0.pipeline(); if (sslCtx != null) { p.addLast(sslCtx.newHandler(arg0.alloc())); } p.addLast("decoder", new HttpRequestDecoder()); p.addLast("encoder", new HttpResponseEncoder()); p.addLast(new CorsHandler(corsConfig)); p.addLast(new EduMsgNettyServerHandler()); }
From source file:godfinger.http.HttpServerInitializer.java
License:Apache License
@Override public void initChannel(SocketChannel channel) { CorsConfig corsConfig = CorsConfig.withAnyOrigin().allowCredentials() .allowedRequestMethods(HttpMethod.GET, HttpMethod.POST, HttpMethod.PUT, HttpMethod.DELETE) .allowedRequestHeaders("accept", "content-type", "session-id").build(); ChannelPipeline pipeline = channel.pipeline(); pipeline.addLast(new HttpServerCodec()); pipeline.addLast(new FaviconHandler()); pipeline.addLast(new CorsHandler(corsConfig)); pipeline.addLast(new HttpObjectAggregator(1024 * 1024)); pipeline.addLast(new HttpRequestHandler(requestProcessor)); }
From source file:io.blobkeeper.server.initializer.BlobKeeperServerInitializer.java
License:Apache License
@Override protected void initChannel(SocketChannel socketChannel) throws Exception { CorsConfig corsConfig = CorsConfig.withAnyOrigin().allowedRequestMethods(DELETE, GET, OPTIONS, POST, PUT) .allowedRequestHeaders(serverConfiguration.getAllowedHeaders()).build(); ChannelPipeline pipeline = socketChannel.pipeline(); pipeline.addLast("decoder", new HttpRequestDecoder()); pipeline.addLast("encoder", new HttpResponseEncoder()); pipeline.addLast("chunkedWriter", new ChunkedWriteHandler()); pipeline.addLast("cors", new CorsHandler(corsConfig)); pipeline.addLast("writer", fileWriterHandlerProvider.get()); pipeline.addLast("reader", fileReaderHandler); pipeline.addLast("deleter", fileDeleteHandler); }
From source file:nayan.netty.server.HttpStaticFileServerInitializer.java
License:Apache License
@Override public void initChannel(SocketChannel ch) throws Exception { // Create a default pipeline implementation. CorsConfig corsConfig = CorsConfig.withAnyOrigin().build(); ChannelPipeline pipeline = ch.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("encoder", new HttpResponseEncoder()); pipeline.addLast("decoder", new HttpRequestDecoder()); pipeline.addLast("aggregator", new HttpObjectAggregator(8388608)); // 8MB //pipeline.addLast("chunkedWriter", new ChunkedWriteHandler()); pipeline.addLast("cors", new CorsHandler(corsConfig)); pipeline.addLast("handler", new HttpStaticFileServerHandler()); }
From source file:ozy.server.ServerInitializer.java
License:Open Source License
@Override public final void initChannel(SocketChannel ch) { // NOTE: If it becomes necessary to order multiple client requests, an example may still exist // at this link: http://adolgarev.blogspot.com/2013/12/lets-do-our-own-full-blown-http-server.html CorsConfig corsConfig = CorsConfig.withAnyOrigin().allowedRequestMethods(GET, POST, PUT, DELETE).build(); ChannelPipeline p = ch.pipeline();/*from w w w . j a va 2s .co m*/ p.addLast("requestDecoder", new HttpRequestDecoder()); p.addLast("objectAggregator", new HttpObjectAggregator(1048576)); p.addLast("responseEncoder", new HttpResponseEncoder()); p.addLast("corsHandler", new CorsHandler(corsConfig)); p.addLast("serverHandler", new ServerHandler(_server)); }