Exemplo n.º 1
0
 public void OperationComplete(ChannelFuture future)
 {
     if (future.IsSuccess())
     {
         ctx.Channel().Read();
     }
     else
     {
         SimpleHttpProxyHandler.Log.Debug("Proxy failed. Cause: ", future.Cause());
         future.Channel().Close();
     }
 }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 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);
     }
 }
Exemplo n.º 4
0
 /// <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();
     }
 }