public void OperationComplete(ChannelFuture future)
 {
     if (future.IsSuccess())
     {
         ctx.Channel().Read();
     }
     else
     {
         SimpleHttpProxyHandler.Log.Debug("Proxy failed. Cause: ", future.Cause());
         future.Channel().Close();
     }
 }
        protected override void ChannelRead0(ChannelHandlerContext ctx, HttpRequest req)
        {
            uri = req.GetUri();
            IO.Netty.Channel.Channel     client        = ctx.Channel();
            IO.Netty.Bootstrap.Bootstrap proxiedServer = new IO.Netty.Bootstrap.Bootstrap().Group
                                                             (client.EventLoop()).Channel(typeof(NioSocketChannel)).Handler(new _ChannelInitializer_106
                                                                                                                                (this, client));
            ChannelFuture f = proxiedServer.Connect(host);

            proxiedChannel = f.Channel();
            f.AddListener(new _ChannelFutureListener_115(this, ctx, req, client));
        }
示例#3
0
 public virtual void Start()
 {
     if (httpServer != null)
     {
         ChannelFuture f = httpServer.Bind(DataNode.GetInfoAddr(conf));
         f.SyncUninterruptibly();
         httpAddress = (IPEndPoint)f.Channel().LocalAddress();
         Log.Info("Listening HTTP traffic on " + httpAddress);
     }
     if (httpsServer != null)
     {
         IPEndPoint secInfoSocAddr = NetUtils.CreateSocketAddr(conf.GetTrimmed(DFSConfigKeys
                                                                               .DfsDatanodeHttpsAddressKey, DFSConfigKeys.DfsDatanodeHttpsAddressDefault));
         ChannelFuture f = httpsServer.Bind(secInfoSocAddr);
         f.SyncUninterruptibly();
         httpsAddress = (IPEndPoint)f.Channel().LocalAddress();
         Log.Info("Listening HTTPS traffic on " + httpsAddress);
     }
 }
 /// <exception cref="System.Exception"/>
 public void OperationComplete(ChannelFuture future)
 {
     if (future.IsSuccess())
     {
         ctx.Channel().Pipeline().Remove <HttpResponseEncoder>();
         HttpRequest newReq = new DefaultFullHttpRequest(HttpVersion.Http11, req.GetMethod
                                                             (), req.GetUri());
         newReq.Headers().Add(req.Headers());
         newReq.Headers().Set(HttpHeaders.Names.Connection, HttpHeaders.Values.Close);
         future.Channel().WriteAndFlush(newReq);
     }
     else
     {
         DefaultHttpResponse resp = new DefaultHttpResponse(HttpVersion.Http11, HttpResponseStatus
                                                            .InternalServerError);
         resp.Headers().Set(HttpHeaders.Names.Connection, HttpHeaders.Values.Close);
         SimpleHttpProxyHandler.Log.Info("Proxy " + this._enclosing.uri + " failed. Cause: "
                                         , future.Cause());
         ctx.WriteAndFlush(resp).AddListener(ChannelFutureListener.Close);
         client.Close();
     }
 }